Преглед на файлове

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

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