(defun is-var (expr)
"is this a variable (i.e. starts with ?)"
(and (symbolp expr) (eql (char (symbol-name expr) 0) #\?)))
(defun find-vars (expr)
"returns a list of all the variables in expr"
(if (consp expr) (append (find-vars (car expr)) (find-vars (cdr expr))) ;; Kак этот append работает?
(if (is-var expr) (list expr) nil)))
тестирую append
CL-USER 2 > (append 'Z '(a sd))
Error: Z (of type SYMBOL) is not of type LIST.
CL-USER 3 : 1 > (append (car '(1 2 3)) (cdr '(1 2 3)))
Error: 1 (of type FIXNUM) is not of type LIST.
CL-USER 17 > (append (car '(s d f)) (cdr '(1 2 3)))
Error: S (of type SYMBOL) is not of type LIST.
А ведь тут работает, почему?
CL-USER 13 > (find-vars '?)
(?)
CL-USER 16 > (find-vars '(s d ?))
(?)