What is (cons '(a) '(b)) ?

  • A: (a b)
  • B: ((a) (b))
  • C: ((a) b)
  • D: ((a b))
  • E: error

    Answer: C

    cons adds one new item to the front of a linked list: (cons 'a '(b c)) = (a b c).

    In this case, the new item is a sublist, (a).

    Rule: In (cons '(a) '(b)), that is (cons first rest), move the left paren of the rest argument to the left of the first argument; that is the answer.

    Page-10    Prev    Next    Page+10