CS 7520 Homework II-12

Start with the ISWIM Redex model from chapter II-12 in the book: iswim.rkt

Part 1

Define an if0 meta-function that serves as a macro. For example, with your definition, (term (if0 0 2 3)) should reduce to (term 2), while (term (if0 1 2 3)) should reduce to (term 3).

You do not need to change the grammar or evaluation rules – just add a meta-function definition for if0.

Part 2

Define a Racket constant Y that represents the Yv function from section I-4.4 of the book.

With your definition, (term ((,Y (λ f (λ x (f x)))) 0)) should loop forever, while (term ((,Y (λ f (λ x 5))) 0)) should reduce to (term 5).

Part 3

Define a Racket constant fact that represents the factorial function.

With your definition,

Beware that Redex's traces automatically stops after a certain number of steps. You may need to click the Reduce button to trigger more steps.


Last update: Wednesday, February 9th, 2011
mflatt@cs.utah.edu