{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework4

# Homework4 - For the following RPAL program let(a = 2 within...

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

COP 5555 Programming Language Principles Homework 4 Assigned: Jun. 8, 2011 Deadline: 11:59pm Jun. 15, 2011 *Note: Please submit your solution to the e-learning system by the deadline. No late submission is allowed. 1. Problem 1 (25 Points) 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

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

View Full Document
2. Problem 2 (25 Points)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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. 3. Problem 3 (25 Points) 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 4. Problem 4 (25 Points) 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

{[ snackBarMessage ]}

### Page1 / 2

Homework4 - For the following RPAL program let(a = 2 within...

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

View Full Document
Ask a homework question - tutors are online