diff options
author | sefidel <contact@sefidel.net> | 2022-02-10 00:24:03 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2022-02-10 00:24:03 +0900 |
commit | 72d448e384249103748ee83b587c45924e4bc44d (patch) | |
tree | 2aa05a6aaf8c7aa37a8c278fd2fede6e62ff2218 /fnl/nvrc/macro/thread.fnl | |
download | nvimrc-72d448e384249103748ee83b587c45924e4bc44d.tar.gz nvimrc-72d448e384249103748ee83b587c45924e4bc44d.zip |
Initial commit
Diffstat (limited to 'fnl/nvrc/macro/thread.fnl')
-rw-r--r-- | fnl/nvrc/macro/thread.fnl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fnl/nvrc/macro/thread.fnl b/fnl/nvrc/macro/thread.fnl new file mode 100644 index 0000000..9060b04 --- /dev/null +++ b/fnl/nvrc/macro/thread.fnl @@ -0,0 +1,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->} |