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 no matter what foo is; (partial contains? (intersection)) => identity).
The problem would be what to do with seq? Ideally an infinite seq that will
produce any particular value after finite time would be produced, but
there's no way to sensibly produce "any particular value" given the wide
variety of constructor semantics, builders, factory methods, things not
known to this particular runtime instance but that conceptually exist
somewhere, etc.; of course, the seq return is a dummy of sorts anyway since
you couldn't really use it sensibly to it might as well just return
(range). Printing should likely be overridden to just print
"(intersection)" rather than b0rk the REPL with a neverending stream of
integers (or whatever).

But then it also subtly violates another property of Clojure set objects:
if (= a b), (not (identical? a b)), and (identical? (a-set a) a), then
(identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The
latter is true under the hypothesis for every "real" set but would be false
for (intersection).

Perhaps this is why (intersection) is not supported at this time, even
though (union) returns an empty set object, the identity element for the
union operation.


On Fri, Jan 24, 2014 at 3:34 PM, Jarrod Swart <jcsw...@gmail.com> wrote:

> Ah cool, thanks for posting your solution!
>
> On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:
>
>> Jarrod Swart <jcs...@gmail.com> writes:
>>
>> > The reason you can't get this to work is that r/map returns a
>> <reducible>
>> > not a <coll> 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/foldcat (r/map set [[1 2] [3 1] [1 3]])))
>>
>> Bye,
>> Tassilo
>>
>  --
> --
> 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/groups/opt_out.
>

-- 
-- 
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/groups/opt_out.

Reply via email to