The docs cover this information under "Creating Transducers", but it
doesn't make clear that the same pattern applies to reducing functions as
well.
- James
On 5 December 2014 at 14:15, Ivan Mikushin wrote:
> Thanks for the answers!
>
> BTW there isn't a word in the docs (http://clojure.org/tra
Thanks for the answers!
BTW there isn't a word in the docs (http://clojure.org/transducers and
http://clojure.github.io/clojure/branch-master/clojure.core-api.html#clojure.core/transduce)
about the intended use of arity-1 of the reducing function f.
@Gary, thanks for suggesting to watch the t
I find these examples very memorable. Despite the doc strings clearly
stating the differences between transduce and reduce, one can still hastily
assume that transducing [0 1 2] will have 0 as the init argument.
I will add that the culprit is in defining the +ten's arguments with [&
args] form,
Maybe watching Rich Hickey's talk at the conj will make what is happening
clearer?
It's basically what James said, but with a lot more details and a few
examples.
On Friday, 5 December 2014, James Reeves wrote:
> Reducing functions have three arities:
>
> 0-arity: returns the initial state
> 1-
Reducing functions have three arities:
0-arity: returns the initial state
1-arity: handles completion
2-arity: reduce step function
Using arities to denote different functionality is a little odd, but it
does make sense for functions like addition and conjoin:
(+) => 0
(+ 1) => 1
(+
First: transducers are a very cool idea, and I'm really looking forward to
clojure 1.7 release when we'll be able to use them in production code.
Now, clojure 1.7 is still alpha, so here's my feedback while it's not (too)
late.
transduce has a pretty unintuitive behaviour. Suppose, you've got