The reader macro #()
for anonymous functions is a good candidate here:
(-> your-arg (fn1 arg2 arg3) (fn2 arg4 arg5) (
It is flexible and adds a bit of visual noise. Of course, you can do many different things, in this case the application with the partial function will also work:
(-> your-arg (fn1 arg2 arg3) ((partial fn2 arg4 arg5)))
There is also a macro ->>
, which processes the first expression in the last position. Of course, this doesnβt help much in your use case, since you have to adjust some function calls. However, if you chain many functions that should take an expression as the first argument, and then many functions that take an expression as the last argument, you could do something like
(->> (-> your-arg (fn1 arg2 arg3) (fn2 arg5 arg6)) (fn3 arg7 arg8) (fn4 arg10 arg11))
EDIT: In the first example, an extra bracket is added.
source share