mirror of
https://github.com/kanaka/mal.git
synced 2024-10-27 22:58:00 +03:00
bbc-basic: Define 'cond' and 'or' macros at startup, completing step 8.
This commit is contained in:
parent
0e159177ca
commit
938f8c023c
@ -21,6 +21,8 @@ REM Initial forms to evaluate
|
||||
RESTORE +0
|
||||
DATA (def! not (fn* (a) (if a false true)))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
|
||||
DATA (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)))))))
|
||||
DATA (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))))))))
|
||||
DATA ""
|
||||
REPEAT
|
||||
READ form$
|
||||
|
Loading…
Reference in New Issue
Block a user