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:
Christopher Allan Webber 2013-04-01 10:33:45 -05:00
parent a0acbd7948
commit 9416422330
2 changed files with 4 additions and 5 deletions

View File

@ -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

View File

@ -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 []