X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=assignment1.mdwn;h=bfaafdc0acae1d1cad18d6bfdf36c927ba2ded0a;hp=cb1dfd2996a071c9f110ac1ecd4bdf7e9c5e31ac;hb=567ca6641f7c2f470cd0003e32efeab52ab9c9c9;hpb=fe9676f755081fce2220593c995e21f5e24f6c76 diff --git a/assignment1.mdwn b/assignment1.mdwn index cb1dfd29..bfaafdc0 100644 --- a/assignment1.mdwn +++ b/assignment1.mdwn @@ -26,30 +26,32 @@ In Racket, these can be defined like this: (define true (lambda (t) (lambda (f) t))) (define false (lambda (t) (lambda (f) f))) - [8] Define a "neg" operator that negates "true" and "false". +* Define a "neg" operator that negates "true" and "false". Expected behavior: - (((neg true) 10) 20) + (((neg true) 10) 20) evaluates to 20, and - (((neg false) 10) 20) + (((neg false) 10) 20) evaluates to 10. - [9] Define an "and" operator. +* Define an "and" operator. - [10] Define an "xor" operator. (If you haven't seen this term before, here's a truth table: +* Define an "xor" operator. +(If you haven't seen this term before, here's a truth table: - true xor true = false - true xor false = true - false xor true = true - false xor false = false + true xor true = false + true xor false = true + false xor true = true + false xor false = false ) - 11. Inspired by our definition of boolean values, propose a data structure -capable of representing one of the two values "black" or "white". If we have +* Inspired by our definition of boolean values, propose a data structure +capable of representing one of the two values "black" or "white". +If we have one of those values, call it a black-or-white-value, we should be able to write: @@ -60,7 +62,7 @@ if-white, depending on which of the black-or-white values we started with. Give a definition for each of "black" and "white". (Do it in both lambda calculus and also in Racket.) -12. Now propose a data structure capable of representing one of the three values +* Now propose a data structure capable of representing one of the three values "red" "green" or "blue," based on the same model. (Do it in both lambda calculus and also in Racket.)