Added ap-pipe and ap-compose macros
`ap-pipe` is an anaphoric version of `->` and `->>`. It is useful for specifying where the argument should go in each expression. `ap-compose` returns a function which is the composition of several anaphoric forms.
This commit is contained in:
parent
3d41630219
commit
d3d24db8bd
@ -109,3 +109,15 @@
|
||||
`(let [[acc ~initial-value]]
|
||||
(ap-each ~lst (setv acc ~form))
|
||||
acc)))
|
||||
|
||||
|
||||
(defmacro ap-pipe [var &rest forms]
|
||||
"Pushes a value through several forms.
|
||||
(Anaphoric version of -> and ->>)"
|
||||
(if (empty? forms) var
|
||||
`(ap-pipe (let [[it ~var]] ~(first forms)) ~@(rest forms))))
|
||||
|
||||
|
||||
(defmacro ap-compose [&rest forms]
|
||||
"Returns a function which is the composition of several forms."
|
||||
`(fn [var] (ap-pipe var ~@forms)))
|
||||
|
Loading…
Reference in New Issue
Block a user