### Useful Lisp

• (every function list)
True if the function is true for every element of list.
(every #'numberp '(1 23 7)) = T
• (some function list)
True if the function is true (non-NIL) for some element of list; returns the first non-NIL value.
(some #'(lambda (x) (if (numberp x) x)) '(a b 3 c 7)) = 3
• (subset function list)         (defined in the file macros.lsp)
Returns the subset of list for which function is true (non-NIL).
(subset #'numberp '(a b 3 c 7)) = (3 7)
• (mapcar function list)
Applies function to each element of list; returns a list of the results.
(mapcar #'(lambda (x) (+ x 2)) '(1 2 3)) = (3 4 5)
• (mapc function list)
Like mapcar, but does not make a list of results.
(mapc #'(lambda (x) (if (> x 3) (print x))) '(2 4 6))
• (mapcan function list)
Applies function to each element of list; returns a concatenated list of the results (each of which should be a list).
(mapcan #'(lambda (x) (if (evenp x) (list x))) '(1 2 3 4)) = (2 4)
• (intersection list1 list2)
Set intersection. Also defined are union and set-difference.
(intersection '(a b c) '(a c e)) = (C A)
• (subst x y z)
Substitute x for y in z.
(subst 'sugar 'cream '(peaches and cream)) = (PEACHES AND SUGAR)
• (sublis alist z)
Substitute from the alist (a list of pairs, (old . new)) in z.
(sublis '((rose . peach) (smell . taste))
'(a rose by any other name would smell as sweet))

= (A PEACH BY ANY OTHER NAME WOULD TASTE AS SWEET)
• (eval code)
Evaluate (execute) code.
(eval (subst 5 'r '(* pi (expt r 2)))) = 78.5398
• (apply function args)
Apply (call) the function on arguments args.
(apply #'+ '(2 3)) = 5
• (funcall function arg1 ... argn)
Call the function on arguments arg1 ... argn.
(funcall (get (car form) 'derivfn) form var)
• (get symbol property)
Get the value of property for the symbol; if no such property is defined, the result is NIL.
(get person 'age)
• (setf (get symbol property) value)
Define the property of symbol to be value.
(setf (get 'john 'age) 27)

Gordon S. Novak Jr.