CS212 Exams
Spring 1997 - Prelim 1

List Structures


(17 Points) List structures in Scheme are printed as sequences of elements, enclosed in parentheses. If the final element of a given list structure is not itself a list, this is denoted by printing a dot before that element. For example here is how several different expressions would be printed:
(cons 1 (cons 2 (cons 3 empty))) --> (1 2 3)
(list 1 2 3) --> (1 2 3)
(cons 1 (cons 2 3)) --> (1 2 . 3)
(list (cons 1 2) 3 (list 4 5)) --> ((1 . 2) 3 (4 5))
  1. Draw the box and pointer diagram corresponding to (1 2 . 3)





  2. Draw the box and pointer diagram corresponding to ((1 . 2) 3 (4 5))






Solution

Return to CS 212 Prelim 1 - Spring 1997