It's because the value of the + is captured when the partial is created (or
when the var is implicitly derefed). The value of the var is implicitly
captured (via deref) at the point where it appears in the form.
It's a bit of a complex topic, but this blog post I wrote a few months ago
may help a
Sum-partial-def gets the original + definition because it is evaluated
first, if you want late binding, try (partial reduce (var +)).
On Dec 1, 2016 4:05 PM, "Matthew Hamrick" wrote:
> I'm confused by the following code.
> Could someone explain to me why the def-ed
I'm confused by the following code.
Could someone explain to me why the def-ed partial has different behavior
to the letted one?
This is especially confusing to me since the #() special form one works as
I expect.
(def sum-partial-def (partial reduce +))
(let [sum-partial (partial reduce +)