Define (has-number-p s-exp) to return true if the s-expression is or contains a number.
> (has-number-p 1)
T
> (has-number-p 'a)
NIL
> (has-number-p '(a (b (c d) ((3)))))
T
Solution:(defun has-number-p (s-exp)
(if (atom s-exp)
(if (numberp s-exp) t nil)
(some #'has-number-p s-exp)))
No comments:
Post a Comment