Start with the ISWIM Redex model from chapter II-2 in the book.
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.
Define a Scheme constant Y that represents the
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).
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, 2009mflatt@cs.utah.edu |