From: Jim Pryor Date: Tue, 14 Sep 2010 15:56:56 +0000 (-0400) Subject: more5 assignment1 tweaks X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=1f6748544a73f4bde9fc537750e7da2d13eb3615 more5 assignment1 tweaks Signed-off-by: Jim Pryor --- diff --git a/assignment1.mdwn b/assignment1.mdwn index 453fa546..615e1832 100644 --- a/assignment1.mdwn +++ b/assignment1.mdwn @@ -17,8 +17,8 @@ Booleans Recall our definitions of true and false. -> **true** defined to be `\t \f. t` -> **false** defined to be `\t \f. f` +> **true** is defined to be `\t \f. t` +> **false** is defined to be `\t \f. f` In Racket, these can be defined like this: @@ -75,7 +75,7 @@ Pairs Recall our definitions of ordered pairs. -> the pair **(**x**,**y**)** is defined as `\f. f x y` +> the pair **(**x**,**y**)** is defined to be `\f. f x y` To extract the first element of a pair p, you write: @@ -118,15 +118,13 @@ However, the latter is still what's going on under the hood.
-
1. Define a `swap` function that reverses the elements of a pair. - -Expected behavior: +
2. Define a `swap` function that reverses the elements of a pair. Expected behavior: (define p ((make-pair 10) 20)) ((p swap) get-first) ; evaluates to 20 ((p swap) get-second) ; evaluates to 10 -Write out the definition of swap in Racket. +Write out the definition of `swap` in Racket.
3. Define a `dup` function that duplicates its argument to form a pair