Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
Okay, I see now. Thanks for the Socratic dialogue, at the onset of the day I knew nothing about core.reducers. I feel fairly conversational now! On Friday, January 24, 2014 7:44:03 PM UTC-5, Cedric Greevey wrote: > > No, the identity for intersection is a set that has everything, as > (inter

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
No, the identity for intersection is a set that has everything, as (intersection A Everything) = A no matter what A is. On Fri, Jan 24, 2014 at 7:38 PM, Jarrod Swart wrote: > Good points. But the "identity" thing is still what gets me. What is the > identity of an intersection? > > Like you s

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
Good points. But the "identity" thing is still what gets me. What is the identity of an intersection? Like you said it can't be #{}. If you seed an intersection with #{} you get #{}, so you can't intersect from the empty set. The identity for an intersection is whatever the common element i

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
Intersection is associative and commutative: (intersection A B) = (intersection B A) and (intersection A (intersection B C)) = (intersection (intersection A B) C) = the elements common to all three sets. So it's actually perfectly well-founded for use with reducers, at least in principle, and inter

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Ben Wolfson
On Fri, Jan 24, 2014 at 12:56 PM, Cedric Greevey wrote: > An interesting question this raises is if there is any sensible way to > define (intersection). It would need to behave as an identity element for > intersection, so would need to behave as a set (so, (set? (intersection)) > => truthy) tha

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
If I understand you correctly I am in agreement. I don't think you could take this problem to clojure.core.reducers/reduce or fold because the problem is inherently sequential is it not? The reduction is basically (intersection (intersection (intersection A B) C) D). I was curious of this m

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
An interesting question this raises is if there is any sensible way to define (intersection). It would need to behave as an identity element for intersection, so would need to behave as a set (so, (set? (intersection)) => truthy) that contained everything (so, (contains? (intersection) foo) => foo

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
Ah cool, thanks for posting your solution! On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote: > > Jarrod Swart > writes: > > > The reason you can't get this to work is that r/map returns a > > > not a for reduce to operate on. > > Ah, indeed. I couldn't see the forest for the

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Tassilo Horn
Jarrod Swart writes: > The reason you can't get this to work is that r/map returns a > not a for reduce to operate on. Ah, indeed. I couldn't see the forest for the trees. > I'm not sure of a solution because I'm not familiar with > core.reducers. This works: (reduce set/intersection (r

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
The reason you can't get this to work is that r/map returns a not a for reduce to operate on. I'm not sure of a solution because I'm not familiar with core.reducers. But reading this: http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html informed me