X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=assignment3.mdwn;h=f93afd6110ce1e32550d37639f6f7ac7f3a77bc4;hp=013bc3c5052cd781aad78bb5a82656d5e47505c3;hb=fa5f84861179e2ffcc16dfadffbd4b1c4f01c5df;hpb=f2662f133c25062dc28261f655bb9daf9c2bbb9c diff --git a/assignment3.mdwn b/assignment3.mdwn index 013bc3c5..f93afd61 100644 --- a/assignment3.mdwn +++ b/assignment3.mdwn @@ -4,7 +4,7 @@ Assignment 3 Once again, the lambda evaluator will make working through this assignment much faster and more secure. -*Writing recursive functions on version 1 style lists* +##Writing recursive functions on version 1 style lists## Recall that version 1 style lists are constructed like this: @@ -46,7 +46,7 @@ eq 3 3 Then `length mylist` evaluates to 3. -1. What does `head (tail (tail mylist))` evaluate to? +1. Warm-up: What does `head (tail (tail mylist))` evaluate to? 2. Using the `length` function as a model, and using the predecessor function, write a function that computes factorials. (Recall that n!, @@ -65,11 +65,17 @@ same length. That is, listLenEq mylist (makeList meh (makeList meh nil))) ~~> false +4. Now write the same function, but don't use the length function (hint: use `leq` as a model). + +##Trees## + +Since we'll be working with linguistic objects, let's approximate +trees as follows: a tree is a version 1 list +a Church number is a tree, and +if A and B are trees, then (make-pair A B) is a tree. + -4. Now write the same function (true iff two lists have the same -length) but don't use the length function (hint: use `leq` as a model). - That is, (makeList 1 (makeList 2 (makeList 3 nil))) [The following should be correct, but won't run in my browser: