Start with the ISWIM Redex model from chapter II-12 in the book: iswim.rkt
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 Racket 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 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, 2011mflatt@cs.utah.edu |