Unformatted text preview: calc Function. Write a Function unparse : WAE -> sexp . It should be the leFt inverse oF parse ; that is, iF (parse s) succeeds, then (equal? (unparse(parse p)) p) returns #t . 2. (a) Write a Function lazy-calc : WAE -> number , which is the same as calc except that it uses the “lazy” regime described in PLAI Section 3.4. (a) Give a WAE expression that contains n ’+ operators, and that perForms O ( n ) add operations when evaluated by calc but O (2 n ) add operations when evaluated by lazy-calc . (b) Does lazy-calc always perForm at least as many ’+ operations as calc on a given WAE expression? Prove that this is so, or give a counter-example. 3. Your WAE interpreter behaves di²erently than C/C++/Java/C# when doing arithmetic on integers. Give some examples oF these di²erences. Hint: Think about large numbers. 1...
View Full Document
This note was uploaded on 01/30/2010 for the course CSE 581 taught by Professor Jameshook during the Spring '09 term at Portland State.
- Spring '09