¤ You may use all forms and functions that you know from Intermediate Student. If you need a function and you don't know whether it is provided, define it. You must use loops when required; you may use them otherwise.
¤ Remember that the phrase ``develop a function'' means to design a function according to the design recipe. You are not required to provide a template unless the problem specifically asks for one. However, be prepared to struggle with the development of function bodies if you choose to skip the template step.
¤ You may obtain a maximum of 55 points. Of those, 5 points are extra credit; we will therefore use 50 points as the basis for the evaluation of the exam.
¤ We will not answer any questions during the exam.
Problem$^b$ 1. Take a look at these structure and data definitions:
(define-struct event (slot msg)) ;; An Event is one of: ;; -- Symbol ;; -- String ;; -- (make-event NaturalNumber String)
Answer the following questions in this context:
Write down the constructor and predicate that the structure definition introduces:
Solution [PT 2]
Write down three distinct data examples, one per clause:
Solution [PT 1]
'hello "world" (make-event 10 'hello)
Write down the template for a function that consumes an Event:
;; program : Event -> ???
Solution [PT 2: 1 for three cond lines, 1 for selector expressions]
(define (program e) (cond [(symbol? e) ...] [(string? e) ...] [else (event-slot e) ... (eventmsg e)]))