add and, or macro
This commit is contained in:
parent
75e2344cbe
commit
ba39b84914
22
lib/lib.lisp
22
lib/lib.lisp
@ -1,8 +1,24 @@
|
||||
(macro defun (name args body)
|
||||
`(define ,name (lambda ,args ,body)))
|
||||
|
||||
(macro cond (expr . rest)
|
||||
(if (not expr)
|
||||
nil
|
||||
(let ((test (car expr)))
|
||||
`(if ,test
|
||||
(progn ,test ,@(cdr expr))
|
||||
(cond ,@rest)))))
|
||||
|
||||
(macro and (expr . rest)
|
||||
(if (not rest)
|
||||
expr
|
||||
(if (cond (not expr) nil)
|
||||
`(and ,@rest))))
|
||||
|
||||
(macro or (expr . rest)
|
||||
(if rest
|
||||
(cond (expr) (`(or ,@rest)))
|
||||
expr))
|
||||
|
||||
(defun list (x . y) (cons x y))
|
||||
|
||||
(macro cond (expr . rest)
|
||||
(if (not expr) nil
|
||||
`(if ,(car expr) (progn ,@expr) (cond ,@rest))))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user