Assignment 4 – Programming with λ
Due Thursday 5/2 1:59pm
null, a constant
cons, a function that takes two arguments and returns a cons cell
isnull, a function that returns true if its argument is null, false if it is a cons cell
car, a function that takes a cons cell and returns its first element
cdr, a function that takes a cons cell and returns its second element.
(isnull null) = #true
(isnull (cons M N)) = #false
(car (cons M N)) = M
(cdr (cons M N)) = N
Using this encoding, define length, which takes a list of booleans and returns the number of cons cells in the list. Booleans and Numbers should both be Church-encoded.
Use the lc language to write your solution. Follow the installation instructions on the GitHub page to set it up in your Racket installation. Be sure to include a reasonable set of test cases for each definition.
Deliverables: Upload your file with the solution to canvas.