summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4abee3b)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
Recall our definitions of true and false.
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:
In Racket, these can be defined like this:
Recall our definitions of ordered 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:
To extract the first element of a pair p, you write:
-<LI>Define a `swap` function that reverses the elements of a pair.
-
-Expected behavior:
+<LI>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
(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.
<LI>Define a `dup` function that duplicates its argument to form a pair
<LI>Define a `dup` function that duplicates its argument to form a pair