sicp-ex-2.26



<< Previous exercise (2.25) | Index | Next exercise (2.27) >>


jz

  (define x (list 1 2 3))
  (define y (list 4 5 6))

(append x y) prints

  (1 2 3 4 5 6)

because we're just building the list.

(cons x y) prints

  ((1 2 3) 4 5 6)

because it's a list of 4 elements, where the first element is also a list. Note that (cons a (list b c d)) is the same as (list a b c d).

(list x y) prints

  ((1 2 3) (4 5 6))

because this is a list of two separate elements.