CSU211 Exam 2 - Fall 2004 


Student Id (last 4 digits) :
Instructor's Name:
High School/State:

¤ Write down the answers in the space provided.

¤ 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.

Good luck.

Problem Points
1 7
2 17
3 8
4 10
5 8
X 5
Total 55
Base 50 50


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:

  1. Write down the constructor and predicate that the structure definition introduces:

    Solution [PT 2]

    make-event event? 

  2. Write down three distinct data examples, one per clause:

    Solution [PT 1]

        'hello    "world"      (make-event 10 'hello)

  3. 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)
        [(symbol? e) ...]
        [(string? e) ...]
        [else (event-slot e) ... (eventmsg e)]))

    Last modified: Sunday, November 28th, 2004
    HTML conversion by TeX2page 2004-09-11