浏览代码

Implement a scheme-inspired version of cond.

E.g. you group the forms (test and expr) yourself and else is not yet
supported (though you should be able to just put a `(true ...)` in).
Lucas Stadler 12 年之前
父节点
当前提交
ababe23344
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      clj/macros.clj

+ 8 - 0
clj/macros.clj

@ -0,0 +1,8 @@
1
(ns macros
2
  "Dilettante first steps with macros")
3
4
(defmacro my-cond [& clauses]
5
  (when clauses
6
    `(if ~(ffirst clauses)
7
       ~(second (first clauses))
8
       (my-cond ~@(next clauses)))))