Worksheet #1, Period 1 September 2000


  1. Write a function called cons-all which will take any number if arguments as
    long as the first one is a list. It will put the other arguments into the list.
       Example: (cons-all '(x y) 'a 'b 'c) returns (a b c x y)
          (cons-all '(x y) '(a)) returns ((a) x y)

  2. Write a function called which which will determine the type of argument it receives.
    >   Example (which 'a) returns atom
          (which 7) returns number
          (which '(a b)) returns list
          (which nil) returns empty list

  3. Write a function intersect which will accept two lists as parameters and will
    return the intersection of the two lists.
    >   Example (intersect '(a b c d) '(b d)) returns (b d)
          (intersect '(a b c d) '(w x y)) returns nil
          (intersect '(a b c) '(a b c)) returns (a b c)

  4. Write a function pair-it which will receive 2 parameters, an atom and a list of lists.
    If the atom appears in any of the sublists, return the first appearance of that sublist.
       Example: (pair-it 'a '((m n) (a b) (r s))) returns (a b)
          (pair-it 'x '((a b) (w x) (x y))) returns (w x)
          (pair-it 'q '((a)(b)(c))) returns nil