assn3 - CS 135 Fall 2008 Byron Weber Becker, Ian Goldberg,...

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

View Full Document Right Arrow Icon
Byron Weber Becker, Ian Goldberg, Brad Lushman, Daniel Roche, Troy Vasiga Assignment 3 Due Wednesday, October 1, 10:30am Files to submit: weird.txt , equiv.ss , geometry.ss , and (for the bonus) inside.ss Use the design recipe to create functions, and do your own work. Language level : Beginning Student. Warmup exercises (from HtDP; not to be submitted): 8.2.1, 8.2.2, 8.3.1, 8.3.2, 8.7.1, 6.1.1, 6.3.2 Extra practice exercises (from HtDP; not to be submitted): 8.6.2, 8.6.3, 8.7.2, 6.3.3, 6.4.2, 6.4.3, 7.2.1, 7.2.2 Here are the assignment questions you need to submit: 1. Suppose we add a special form called weird to the grammar of Beginning Student as follows: h exp i = ( weird h exp ih exp i . . . ) The semantics of weird are defined by the following two substitution rules: ( weird exp1 exp2 exp3 . . . ) becomes ( cond [( symbol? exp2 ) 0 ] [ else ( weird ( + exp1 exp2 ) exp3 . . . )]). ( weird exp ) becomes exp . So, for example, the expression ( weird ( weird 1 two 3 4 )) evaluates as: ( weird ( weird 1 two 3 4 )) ; ( weird 1 two 3 4 ) ; ( cond [( symbol? two ) 0 ] [ else ( weird ( + 1 two ) 3 4 )]) ; ( cond [ true 0 ] [ else ( weird ( + 1 two ) 3 4 )]) ; 0 Now, using the semantics given in class for Beginning Student Scheme, along with the definition of weird above, show the complete step-by-step evalutation of each of the following programs. For (a) through (g), assume the following two definitions have already been processed: ( define ( weird-fun a b c ) ( weird a b c )) ( define ( strange a b ) ( cond [( = a b ) ( weird a ( - b ))] [ else ( weird a strange )])) When you can no longer perform any substitutions according to our semantic model, explain why. Place your solutions in a single text file called weird.txt . (a) (
Background image of page 1

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

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

This note was uploaded on 10/21/2010 for the course CS 135 taught by Professor Vasiga during the Fall '07 term at Waterloo.

Page1 / 3

assn3 - CS 135 Fall 2008 Byron Weber Becker, Ian Goldberg,...

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