Guest User

Untitled

a guest
Jul 7th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.57 KB | None | 0 0
  1. ; a. Return T if a list has an even number of elements on the first level, and
  2. ;    NIL otherwise, without counting the elements of the list
  3.  
  4. (defun noEven (l)
  5.     (prog ((x t))
  6.      here
  7.         (cond
  8.             ((null l) (setq x t) (return x))
  9.             ((null (cdr l)) (setq x nil)  (return x))
  10.             (t (setq l (cddr l)))
  11.         )
  12.         (go here)
  13.     )
  14. )
  15.  
  16. ; b. Check whether a linear list is a set
  17.  
  18. (defun isSet (l)
  19.     (prog ((x t))
  20.      there
  21.         (cond
  22.             ((null l) (setq x t) (return x))
  23.             ((member (car l) (cdr l)) (setq x nil)  (return x))
  24.             (t (setq l (cdr l)))
  25.         )
  26.         (go there)
  27.     )
  28. )
Add Comment
Please, Sign In to add comment