{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

assn3

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

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

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 deﬁned 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 deﬁnition of weird above, show the complete step-by-step evalutation of each of the following programs. For (a) through (g), assume the following two deﬁnitions have already been processed: ( deﬁne ( weird-fun a b c ) ( weird a b c )) ( deﬁne ( 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 ﬁle called weird.txt . (a) (

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.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online