6.7

Week 4 Set b

home work!

Programming Language BSL

Due Date Wed at 9pm (Week 4)

Purpose To design some more programs that deal with unions. And a first taste of lists.

Finger Exercises

Exercise 1 From HtDP, 115.

Exercise 2 From HtDP, 129, 131, or 134.

Graded Exercises

Exercise 3 DevelopWe use “develop” here because the function is given plain atomic data, meaning we cannot design the function. decode. The function consumes a String s and produces Posn posn whose x coordinate is the first 1String of s and whose y coordinate is the rest of the string.

If the given string is "", decode signals the error "decode: bad string given".

Hints (1) Skim the first intermezzo. (2) Read the names of the functions in BSL that deal with Strings and 1Strings. While you don’t know much about lists, you know enough to use even those functions that deal with Strings and lists. Then again, you don’t need to do so. You could have solved this problem last week—with different primitive functions.