hwk4 - Problem 2 For the following RPAL program: let (a = 2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 5555 Programming Language Principles Homework 4 Assigned: Jun. 7, 2010 Deadline: 11:59pm Jun. 14, 2010 *Note: Please submit your solution to the e-learning system by the deadline. No late submission is allowed. Problem 1 Reduce the following AE's: (a) (fn p.p+1) 3 (b) (fn p.1+(fn q.q+1) 3) 2 (c) (fn p.1+(fn p.p+1) 3) 2 (d) (fn p. fn q. p+q) 3 4 (e) (fn p. fn q. p+q) 3 (f) (fn p.p) 3 (g) (fn p. fn q. q p) 1 (h) (fn p. fn q. p q) (fn u. u+2) 1 (i) (fn p. fn q. p q) (fn q. q+2) 1 (j) (fn p. fn q. p q) (fn p. fn q. p q) (fn u. u+1) 1 (k) (fn p. fn q. p) 1 3 (l) (fn p. fn q. q) 1 3 (m) (fn p. p+2) ((fn q. q+1) 3) (n) (fn p. p+2) (fn q. q+1) 3 (o) (fn p. p p) 1 (p) (fn p. p p) (fn q. q 1) (q) (fn p. p p) (fn q. fn u. q u) (fn u. u+1) 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Problem 2 For the following RPAL program: let (a = 2 within f x y = x eq 1 -> x + a | x + 1) and g a b = a aug b in g nil (f 3 4) a) Draw the AST. b) Transform the AST to the fully standardized tree. Problem 3 Reduce the following AE's to normal form: (a) (fn a. a+3) [(fn b. 2*b) 7] (b) (fn a. x+1) 2 (c) {fn b. (fn a. b) [(fn a. a a) (fn b. b b)]} 1 (d) (fn c. (fn a. a+1) [(fn a. a+c) 1]) (e) (fn a. (fn a. (fn a. a+1) (a+2)) (a+3)) a (f) (fn b. [fn a. (fn b. b+a+x) (b+2)] [(fn q. fn r. q) b a]) 5 Problem 4 Evaluate the following AE in programming language order. Then estimate the number of beta-reductions necessary to evaluate the same AE in normal order. (fn a.a+a) [(fn b.b+b) {(fn c.c+c) [(fn d.d+d) 2]}]...
View Full Document

This note was uploaded on 01/22/2012 for the course COP 5555 taught by Professor Staff during the Fall '08 term at University of Florida.

Page1 / 2

hwk4 - Problem 2 For the following RPAL program: let (a = 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online