about summary refs log tree commit diff
path: root/fnl/nvrc/macro/thread.fnl
blob: 9060b04671038cc1c14a58c95450b39d75de7ab9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(local {: insert} table)

(lambda as-> [[binding expr] ...]
  "A threading macro where the first argument is the value binded to the
  second argument, which must be a symbol.
  This binding is valid for the whole body of the threading macro."
  (assert-compile (sym? binding) "expected symbol for binding" binding)
  `(let [,binding ,expr
         ,(unpack (accumulate [exprs [] _ expr (ipairs [...])]
                    (doto exprs
                      (insert binding)
                      (insert expr))))]
     ,binding))

{: as->}