EECS 662

Programming Languages

Index
Blog

Fix Test Case

As promised, here is a test case for fix that implements factorial. I’ve also included types so this should be a good test case for your typeof function:

"app (fix (lambda (ie:Nat->Nat) in (lambda (x:Nat) in if (isZero x) then x else x + app ie x - 1))) 5"

You should be able to drop this right into your interp function. I pulled out all the formatting so you can just copy paste. Here’s what the test case looks like with reasonable formatting:

app (fix (lambda (ie:Nat->Nat) in
            (lambda (x:Nat) in
               if (isZero x) then x else x + app ie x - 1)))
	5

You can use bind to create nice names like fact and factorial as we did in class.

This test case is nice because it tests a ton of functionality. If you can get it to interpret successfully, you’re in great shape.