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