CS 4960-01 Homework II-2

Start with the ISWIM Redex model from chapter II-2 in the book.

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 Scheme 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 Scheme 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: Tuesday, February 17th, 2009
mflatt@cs.utah.edu