Allow an empty (cond)

For easier macro writing purposes, allow an empty (cond), that simply
returns nil. Closes #904.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This commit is contained in:
Gergely Nagy 2015-08-18 08:57:42 +02:00
parent 649dd38040
commit ab7d1be001
No known key found for this signature in database
GPG Key ID: 0A083C5F06E0DD42
2 changed files with 23 additions and 19 deletions

View File

@ -67,6 +67,9 @@
bar bar
(if baz (if baz
quux))" quux))"
(if (empty? branches)
nil
(do
(setv branches (iter branches)) (setv branches (iter branches))
(setv branch (next branches)) (setv branch (next branches))
(defn check-branch [branch] (defn check-branch [branch]
@ -86,7 +89,7 @@
(setv cur-branch (check-branch branch)) (setv cur-branch (check-branch branch))
(.append latest-branch cur-branch) (.append latest-branch cur-branch)
(setv latest-branch cur-branch)) (setv latest-branch cur-branch))
root) root)))
(defmacro for [args &rest body] (defmacro for [args &rest body]

View File

@ -231,7 +231,8 @@
"NATIVE: test if cond sorta works." "NATIVE: test if cond sorta works."
(cond (cond
[(= 1 2) (assert (is true false))] [(= 1 2) (assert (is true false))]
[(is None None) (setv x true) (assert x)])) [(is None None) (setv x true) (assert x)])
(assert (= (cond) nil)))
(defn test-index [] (defn test-index []