X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2Fweek2_encodings.mdwn;h=091fb4c5e19d8069a851375db8dc7d28fdfa794a;hp=6adafda04b2cab617a43baac9d0bdb1b36548586;hb=a4d2693effe839524592f4427465ff8d97625302;hpb=3303e8c15d71c68c58c6eec5d6dc7c03e3d6d7bd diff --git a/topics/week2_encodings.mdwn b/topics/week2_encodings.mdwn index 6adafda0..091fb4c5 100644 --- a/topics/week2_encodings.mdwn +++ b/topics/week2_encodings.mdwn @@ -231,6 +231,7 @@ That will evaluate to whatever this does: f (f (f (z, 10), 20), 30) + With a commutative operator like `(+)`, it makes no difference whether you say `fold_right ((+), z) xs` or `fold_left ((+), z) xs`. But with other operators it will make a difference. We can't say `fold_left ((&), []) [10, 20, 30]`, since that would start by trying to evaluate `[] & 10`, which would crash. But we could do this: let @@ -423,7 +424,7 @@ And indeed this is the Church encoding of the numbers: 3 ≡ \f z. f (f (f z))         ; or \f z. f3 z ... -The encoding for `0` is equivalent to `\f z. z`, which we've also proposed as the encoding for `[]` and for `false`. Don't read too much into this. +The encoding for `0` is what we also proposed as the encoding for `[]` and for `false`. Don't read too much into this. Given the above, can you figure out how to define the `succ` function? We already worked through the definition of `cons`, and this is just a simplification of that, so you should be able to do it. We'll make it a homework.