Просмотр исходного кода

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
Родитель
Сommit
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)))))