RosettaCodeData/Task/Extend-your-language/Common-Lisp/extend-your-language.lisp

10 lines
329 B
Common Lisp

(defmacro if2 (cond1 cond2 both first second &rest neither)
(let ((res1 (gensym))
(res2 (gensym)))
`(let ((,res1 ,cond1)
(,res2 ,cond2))
(cond ((and ,res1 ,res2) ,both)
(,res1 ,first)
(,res2 ,second)
(t ,@neither)))))