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 lazycalc : 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 lazycalc . (b) Does lazycalc always perForm at least as many ’+ operations as calc on a given WAE expression? Prove that this is so, or give a counterexample. 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
 JAMESHOOK

Click to edit the document details