X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;f=assignment3.mdwn;h=9039a957b482b1c7e32441f5782a9bee57467bf3;hb=17c72bcdce271a9975bc4cad438754fa4b70c6fc;hp=1ce112ea8d1e6ba21e1886b174614d4e9c156c0e;hpb=daf4849794acb02a9d5393f2da7574b3e1d28cf1;p=lambda.git diff --git a/assignment3.mdwn b/assignment3.mdwn index 1ce112ea..9039a957 100644 --- a/assignment3.mdwn +++ b/assignment3.mdwn @@ -6,7 +6,8 @@ assignment much faster and more secure. *Writing recursive functions on version 1 style lists* -Recall that version 1 style lists are constructed like this: +Recall that version 1 style lists are constructed like this (see +[[lists and numbers]]):
; booleans @@ -35,12 +36,11 @@ let isZero = \n. n (\x. false) true in let succ = \n s z. s (n s z) in let mult = \m n s. m (n s) in let length = Y (\length l. isNil l 0 (succ (length (tail l)))) in -let predecessor = \n. length (tail (n (\p. makeList meh p) nil)) in -let leq = ; (leq m n) will be true iff m is less than or equal to n - Y (\leq m n. isZero m true (isZero n false (leq (predecessor m)(predecessor n)))) in +let pred = \n. isZero n 0 (length (tail (n (\p. makeList meh p) nil))) in +let leq = \m n. isZero(n pred m) in let eq = \m n. and (leq m n)(leq n m) in -eq 3 3 +eq 2 2 yes no