Implement or and cond macros, completes step 8
authorIqbal Ansari <iqbalansari02@yahoo.com>
Sun, 21 Aug 2016 14:52:09 +0000 (20:22 +0530)
committerIqbal Ansari <iqbalansari02@yahoo.com>
Sat, 27 Aug 2016 12:43:33 +0000 (18:13 +0530)
common_lisp/step8_macros.lisp

index c322821..da2b183 100644 (file)
 (rep "(def! not (fn* (a) (if a false true)))")
 (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
 (rep "(def! *ARGV* (list))")
+(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
+(rep "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
 
 (defun readline (prompt &optional (in-stream *standard-input*) (out-stream *standard-output*))
   (format out-stream prompt)