transcendental-lisp/lisp/macro/nif.lisp

10 lines
221 B
Common Lisp

(defun plusp (n) (> n 0))
(defun zerop (n) (= n 0))
(defmacro nif (expr pos zero neg)
(let ((g (gensym)))
`(let ((,g ,expr))
(cond ((plusp ,g) ,pos)
((zerop ,g) ,zero)
(t ,neg)))))