Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.64 KB | None | 0 0
  1. (defun common-2d-vector-p (S)
  2. "Takes an S-expression \(list\) and returns T if it is a two-elemented single-level list of floats and NIL otherwise."
  3.     (cond
  4.         ((atom S) nil) ; Seeing an atom (or a plain NIL)? Not a 2d-vector.
  5.         ((null (car S)) nil) ; Non-empty list containing NIL as its CAR? Not a 2d-vector.
  6.         ((atom (cdr S)) nil) ; NEL containing atomic CDR? Not a 2d-vector - more like 1d-vector or a plain dp.
  7.         (T (cond             ; CAR and CDR are both not NIL, good! Seeking for atomic CAR & CADR next.
  8.             ((and (atom (car S)) (atom (cadr S))) (cond
  9.                                                     ((and (floatp (car S)) (floatp (cadr S))) T)
  10.                                                     (T nil)))
  11.             (T nil)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement