Quellcode durchsuchen

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 vor 12 Jahren
Ursprung
Commit
ababe23344
1 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen
  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)))))