Isoraqathedh

maths-list-p

Feb 15th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.34 KB | None | 0 0
  1. ; A maths list is of the form:
  2. ; (r d d d ...)
  3. ; where r is an operator
  4. ; and d is either a maths list or a number.
  5.  
  6. (defun maths-list-p (expr)
  7.   (if (not (member (first expr) '(+ - * /))) ;check r
  8.       NIL
  9.       (loop
  10.        for i in (rest expr)
  11.        if (not (or (numberp i) (maths-list-p i))) return NIL ;check d
  12.        finally return T)))
Advertisement
Add Comment
Please, Sign In to add comment