Changing cond to be more common lisp / emacs lisp like
Instead of: (cond (condition-1) (body-1) (condition-2) (body-2)) We now work like: (cond ((condition-1) (body-1) (condition-2) (body-2)))
This commit is contained in:
parent
a0acbd7948
commit
9416422330
@ -36,12 +36,11 @@ def defn_macro(tree):
|
||||
def cond_macro(tree):
|
||||
tree.pop(0) # cond flag
|
||||
it = iter(tree)
|
||||
conds = iter(zip(it, it))
|
||||
test, branch = next(conds)
|
||||
test, branch = next(it)
|
||||
|
||||
root = HyExpression([HySymbol("if"), test, branch])
|
||||
ret = root
|
||||
for (test, branch) in conds:
|
||||
for (test, branch) in it:
|
||||
n = HyExpression([HySymbol("if"), test, branch])
|
||||
ret.append(n)
|
||||
ret = n
|
||||
|
@ -78,8 +78,8 @@
|
||||
(defn test-cond []
|
||||
"NATIVE: test if cond sorta works."
|
||||
(cond
|
||||
(= 1 2) (assert (= true false))
|
||||
(is null null) (assert (= true true))))
|
||||
((= 1 2) (assert (= true false)))
|
||||
((is null null) (assert (= true true)))))
|
||||
|
||||
|
||||
(defn test-index []
|
||||
|
Loading…
Reference in New Issue
Block a user