Lab Quiz, Foundations of Computing, Week 9 -- Tues Nov 28 2000

Name:


  1. The expression (read) reads one Scheme expression from the terminal and returns that expression (it does not evaluate the expression). What does (read) return when you type each of the following inputs?

    1. x


    2. (x)


    3. x y z


    4. "x y z"


    5. (x y z)


    6. (x) (y) (z)


    7. (x y
      z)



    8. "x y
      z"



    9. (x (y (z)))


    10. (x (y (z))))


  2. Given these definitions:

    (define (read-three)
      (read) (read) (read))
    
    (define (read-xyz)
      (let ((x (read)))
        (let ((y (read)))
          (let ((z (read)))
            (list x y z)))))
    
    (define (read-list)
      (list (read) (read) (read)))
    
    1. What does (read-three) return when you type this input?
      x y z



    2. What does (read-xyz) return when you type this input?
      x y z



    3. What might (read-list) return when you type this input? Give two different correct answers.
      x y z