6.7

Week 4 Set a

home work!

Programming Language BSL

Due Date Mon at 9pm (Week 4)

Purpose To design some more programs that deal with unions.

Finger Exercises

Exercise 1 From HtDP, 97.

Exercise 2 Design the function create-message. It consumes a 1String s together with a number n and produces a Message.

(define-struct block (name))
(define-struct enable (name))
; A Message is one of:
;  (make-block Number)
;  (make-enable Number)
;  String
; interpretation ... a message from a client to a server ...

If s is "-", create-message creates an instance of block with n as the value of the name field.

For all other 1Strings, create-message creates a string by concatenating s with n (converted to a string).

Graded Exercises

Exercise 3 From HtDP, 109.