For example, this macro adds a simple `if` branch to the `->` macro in clojure.core:
(defmacro -->
"Variation of -> macro that allows anonymous functions without extra parentheses."
[x & forms]
(loop [x x, forms forms]
(if forms
(let [form (first forms)
threaded (if (seq? form)
(if (or (= 'fn* (first form))
(= 'fn (first form)))
(with-meta `(~form ~x) (meta form)) ;; new branch for 'fn 'fn*
(with-meta `(~(first form) ~x ~@(next form)) (meta form)))
(list form x))]
(recur threaded (next forms)))
x)))
(defn test []
(--> 5
inc
#(* % %)
(fn [x] (- x 1))
(vector :b :c)))