hey Sean -- The ones on the reducers reference page:

https://clojure.org/reference/reducers

On Friday, January 25, 2019 at 4:05:12 PM UTC-8, Sean Corfield wrote:

> Which docs are you reading? The docstring for r/fold says this – with no 
> indication of calling (reducef) with no arguments (well, unless you do not 
> supply combinef – in which case reducef will be used for that, so (reducef) 
> would be called to seed the reductions):
>
>  
>
> "Reduces a collection using a (potentially parallel) reduce-combine
>
>   strategy. The collection is partitioned into groups of approximately
>
>   n (default 512), each of which is reduced with reducef (with a seed
>
>   value obtained by calling (combinef) with no arguments). The results
>
>   of these reductions are then reduced with combinef (default
>
>   reducef). combinef must be associative, and, when called with no
>
>   arguments, (combinef) must produce its identity element. These
>
>   operations may be performed in parallel, but the results will
>
>   preserve order."
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> *From: *Brian Craft <javascript:>
> *Sent: *Friday, January 25, 2019 3:36 PM
> *Subject: *r/fold combinef and reducef init values
>
>  
>
> From the docs: 
>
>  
>
> r/fold takes a reducible collection and partitions it into groups of 
> approximately n (default 512) elements. Each group is reduced using the 
> reducef function. The reducef function will be called with no arguments to 
> produce an identity value in each partition. The results of those 
> reductions are then reduced with the combinef (defaults to reducef) 
> function. When called with no arguments, (combinef) must produce its 
> identity element - this will be called multiple times. Operations may be 
> performed in parallel. Results will preserve order.
>
>  
>
> So, this seems to say r/fold will partition the collection and reduce each 
> partition using the (reducef) as the init value.
>
>  
>
> Then, all these intermediate results will be reduced with combinef, using 
> (combinef) as the init value.
>
>  
>
> However, in test it seems (reducef) is never called, and (combinef) is 
> used as the init value for calls to reducef.
>
>  
>
>   (defn combinef
>
>     ([] {:combine :f})
>
>     ([acc v] acc))
>
>  
>
>   (defn reducef
>
>     ([] {:reduce :f})
>
>     ([acc v]
>
>      (println "acc" acc "v" v)
>
>      v))
>
>  
>
>   (clojure.core.reducers/fold combinef reducef ["foo" "bar"])
>
>  
>
> ; outputs:
>
> acc {:combine :f} v foo
>
> acc foo v bar
>
> "bar"
>
>  
>
> The accumulator in reducef is the init value from combinef, not the init 
> value from reducef.
>
>  
>
> What's going on?
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com <javascript:>
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com <javascript:>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>  
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to