transcendental-lisp/lisp/macro/nif.lisp

10 lines
221 B
Common Lisp
Raw Permalink Normal View History

2017-03-13 10:15:05 -04:00
(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)))))