;; find free (undefined) variables in expr
(define free-vars
(lambda (expr . args)
(cond ((symbol? expr) (if (defined? expr) '() expr))
((atom? expr) '())
((list? expr) (flatten (map free-vars expr)))
(else (error)))))