projects
/
lambda.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more5 assignment1 tweaks
[lambda.git]
/
assignment1.mdwn
diff --git
a/assignment1.mdwn
b/assignment1.mdwn
index
453fa54
..
615e183
100644
(file)
--- a/
assignment1.mdwn
+++ b/
assignment1.mdwn
@@
-17,8
+17,8
@@
Booleans
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:
@@
-75,7
+75,7
@@
Pairs
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:
@@
-118,15
+118,13
@@
However, the latter is still what's going on under the hood.
<OL start=13>
<OL start=13>
-<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