X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=lists_and_numbers.mdwn;h=571ed7b8e6295c2f3d7d4f71bd84b3c93c0e1ace;hp=6640d1704d6ebee5fb5750dba3916f48449ce775;hb=0a3e9b7715490e9edefb87397cad3210e790053f;hpb=eaf3e66b4eae5288cd6fabbc8fde051c391821ac diff --git a/lists_and_numbers.mdwn b/lists_and_numbers.mdwn index 6640d170..571ed7b8 100644 --- a/lists_and_numbers.mdwn +++ b/lists_and_numbers.mdwn @@ -1,3 +1,5 @@ +[[!toc]] + Building Lists ============== @@ -275,10 +277,14 @@ So, for example: Adding *m* to *n* is a matter of applying the successor function to *n* *m* times. And we know how to apply an arbitrary function s to *n* *m* times: we just give that function s, and the base-value *n*, to *m* as arguments. Because that's what the function we're using to implement *m* *does*. Hence **add** can be defined to be, simply: - \m \n. m succ n + \m n. m succ n Isn't that nice? +Alternatively, one could do: + + \m n. \s z. m s (n s z) + How would we tell whether a number was 0? Well, look again at the implementations of the first few numbers:
``````zero ≡ \s z. s0 z ≡ \s z. z
``````