AI Worksheet #1
-
Write a function called cons-all which will take any number of 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 (x y a b c)
(cons-all '(x y) '(a)) returns (x y (a))
-
Write a function called "which", that 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
-
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)
-
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