This week, we're composers. https://clojuredesign.club/episode/079-compose-thyself/
Maybe I missed it, but in the episode on partial
, I think you missed one important aspect. One is that partial f ...
is not equivalent to #(f ... %)
(even if f
is unary). If ...
is impure, then it will only be evaluated once for partial, but upon every call for #()
. If it is pure, then you need to decide whether you want the argument recomputed or not. So while I usually use #()
I end up using partial specifically when I have a non-trivial expression that I want to fix as the first argument, instead of doing (let [x ...] #(f x %))
. The other big reason for me is when I have nested lambdas, since #()
doesn't nest, and I for some reason don't want to introduce a fn
form.
@lodin.johan Ah yes, we did not talk about when arguments are evaluated. I like your point about binding the result of the computation vs re-computing every time.
In today's episode, we do bring up the issue of nested #()
. I've been programming in Clojure for 6 years now and I still trip over that from time to time!