X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=exercises%2F_assignment7.mdwn;h=d351b1b5009ff630fdeb82578f8a816697c00ed0;hp=cd798ab078ad9b86f986a8f40d396a487b579c3b;hb=e4595e108f35403bf2981994630db604037c7575;hpb=ef351afc1578508e294f73be1c2f2445463d6383 diff --git a/exercises/_assignment7.mdwn b/exercises/_assignment7.mdwn index cd798ab0..d351b1b5 100644 --- a/exercises/_assignment7.mdwn +++ b/exercises/_assignment7.mdwn @@ -23,3 +23,28 @@ notes, prove that the evaluator does reduce expressions inside of does not perform reductions in those positions. + +3. In the previous homework, one of the techniques for controlling +evaluation order was wrapping expressions in a `let`: `let x = blah in +foo`, you could be sure that `blah` would be evaluated by the time the +interpreter considered `foo` (unless you did some fancy footwork with +thunks). That suggests the following way to try to arrive at eager +evaluation in our Haskell evaluator for CL: + + reduce4 t = case t of + I -> I + K -> K + S -> S + FA a b -> + let b' = reduce4 b in + let a' = reduce4 a in + let t' = FA a' b' in + if (is_redex t') then reduce4 (reduce_one_step t') + else t' + +Will this work? That is, will `reduce4 (FA (FA K I) skomega)` go into +an infinite loop? Run the code to find out, if you must, but write +down your guess (and your rationale) first. + + +