X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;ds=inline;f=assignment3.mdwn;h=e240b732b1405e176d696bbab3c5974a1d125f35;hb=db89aab6e40647f64f6f51ed6281c0cbce361550;hp=9c0d2d836476078c8aa012a08600b2ed8b5f621d;hpb=94f47d126b9513c2a198eba685d44030bc31ac1d;p=lambda.git
diff --git a/assignment3.mdwn b/assignment3.mdwn
index 9c0d2d83..e240b732 100644
--- a/assignment3.mdwn
+++ b/assignment3.mdwn
@@ -12,7 +12,7 @@ originally read
This has been corrected below, and in the preloaded evaluator for
working on assignment 3, available here: [[assignment 3 evaluator]].
-
+
Once again, the lambda evaluator will make working through this
assignment much faster and more secure.
@@ -42,6 +42,7 @@ Recall that version 1 style lists are constructed like this (see
; church numerals
let iszero = \n. n (\x. false) true in
let succ = \n s z. s (n s z) in
+ let add = \l r. l succ r in
let mul = \m n s. m (n s) in
let pred = (\shift n. n shift (make\_pair 0 0) get\_snd) (\p. p (\x y. make\_pair (succ x) x)) in
let leq = \m n. iszero(n pred m) in
@@ -50,6 +51,7 @@ Recall that version 1 style lists are constructed like this (see
; a fixed-point combinator for defining recursive functions
let Y = \f. (\h. f (h h)) (\h. f (h h)) in
let length = Y (\length l. isempty l 0 (succ (length (tail l)))) in
+ let fold = Y (\f l g z. isempty l z (g (head l)(f (tail l) g z))) in
eq 2 2 yes no