let tb = (make_list t12 t3) in
This has been corrected below, and in the preloaded evaluator for
-working on assignment 3.
-
+working on assignment 3, available here: [[assignment 3 evaluator]].
+<hr>
Once again, the lambda evaluator will make working through this
assignment much faster and more secure.
; 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
; 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