mt2004soln

# mt2004soln - University of Waterloo CS 135 Midterm Exam...

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: University of Waterloo CS 135 Midterm Exam Fall 2004 CS 135: Designing Functional Programs Instructor: Prabhakar Ragde November 1, 2004 Start time: 7:00 PM. End Time: 9:00 PM. Duration: 120 minutes Number of exam pages (including this cover sheet): 12 CLOSED BOOK (UW-supplied calculator permitted) Name: Student Number: Signature: # Points Possible Score Comments 1 10 2 10 3 10 4 10 5 10 6 10 Total 60 Mark 100 Directions Write your name and student ID number on every page. If you need extra paper for a question, use the back of that question’s page. If you need more paper beyond this, ask the proctors for blank pages. It is your responsibility to ensure that any extra pages are stapled to this exam. Please write neatly and legibly, and make proper use of indentation and white space. You are communicating with your markers. 1 Name: Student Number: Name: Student Number: Name: Student Number: 1. (10 Points) Given that the following definitions have been processed in the Beginning Student language: ( define n 10 ) ( define m ( * 5 n )) ( define ( f x ) ( * x n )) show the result of the specified number of simplification steps on each of the following expressions. A simplification step consists of one substitution as described by the semantic model of the Beginning Student language. If at any point you cannot carry out a requested simplification step, explain why. (a) Simplify ( f n ) for three steps. ( f n ) = > ( f 10 ) = > ( * 10 n ) = > ( * 10 10 ) (b) Simplify ( cons f ( cons n empty )) for one step. This causes a syntax error, as f is not an expression. (c) Simplify ( f m ) for two steps. ( f m ) = > ( f 50 ) = > ( * 50 n ) (d) Simplify ( f ( cons 10 empty )) for two steps. ( f ( cons 10 empty )) = > ( * ( cons 10 empty ) n ) = > ( * ( cons 10 empty ) 10 ) Note that the next simplification step would cause a run-time error....
View Full Document

{[ snackBarMessage ]}

### Page1 / 6

mt2004soln - University of Waterloo CS 135 Midterm Exam...

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

View Full Document
Ask a homework question - tutors are online