6.7

Week 5 Set b

home work!

Programming Language BSL+

Due Date Wed at 9pm (Week 5)

Purpose Designing functions that create lists

Finger Exercises

Exercise 1 From HtDP, 150 and 151.

Exercise 2 Also from HtDP, 177 and 179.

Graded Exercises

Exercise 3 Design lasts*. The function consumes a list of Strings. It extracts the last 1Strings from each of the strings on the given list and forms a list from those. If one of these strings is "", lasts* adds "-" to the result list.

Exercise 4 Design command. The function consumes a string and produces a Cmd.

; A Cmd is one of:
;  String
;  (cons "-" (cons String '()))
;  (cons "&" (cons String '()))
;  (cons "+" (cons String '()))
; interpretation The message are instructions to the chat server:
;  (cons "-" (cons n '())) means block n from
;    sending messages to this client
;  (cons "&" (cons u '())) means u is a URL to
;    a PNG image
;  (cons "+" (cons n '())) means allow n to
;    send URL messages

If the string starts with "-", "&", or "+", the result is a list whose first item is this 1String and whose second item is the remainder of the given String. The server will check whether the second item of the message conforms to the above interpretation.

In all other cases, command returns the given string.