Hi Randy,

Several functions in clojure.set allow non-set arguments and this has been 
an issue with a long history. There have been or are tickets like this, 
such as http://dev.clojure.org/jira/browse/CLJ-1682 (although this one is 
re intersection).

This was done somewhat intentionally for performance reasons - rather than 
validate or transform, just assume they are sets - their behavior when 
passed non-sets is considered undefined. However, I think this is worth 
revisiting in light of where we are today vs then. I do not know of a jira 
specific to clojure.set/union - you are welcome to create one via the 
contribution process documented 
at http://clojure.org/community/contributing. 

Alex


On Friday, March 4, 2016 at 11:40:28 AM UTC-5, Randy J. Ray wrote:
>
> Hi,
>
> Fairly-new Clojure enthusiast here, currently using Clojure to work 
> through projecteuler.net problems as a means of learning. While using 
> sets on one of the PE problems, I encountered what *might* be a bug. I 
> admit that I haven't searched the backlog of messages from this group or 
> the issues on GitHub, so if this is already known I apologize.
>
> Here is the issue: I discovered that I could pass a list as the second 
> parameter to set/union, and it would be merged into the the set passed as 
> the first parameter and the new resulting set returned. However, if the 
> number of items in the list exceeds the number of items in the set, then 
> the return value is a list with any duplicate elements completely present.
>
> To illustrate, here is a snippet from my REPL:
>
> user=> (require '[clojure.set :as set])
> nil
> user=> (set/union #{1 2 3} #{2 3 4})
> #{1 4 3 2}
> user=> (set/union #{1 2 3} #{2 3 4 5})
> #{1 4 3 2 5}
> user=> (set/union #{1 2 3} (list 2 3 4))
> #{1 4 3 2}
> user=> (set/union #{1 2 3} (list 2 3 4 5))
> (2 3 1 2 3 4 5)
>
> Note that the last expression yields a list of 7 elements rather than a 
> set of 5.
>
> I have not tried this with more than two arguments, so I don't know that 
> would affect the output. I did try putting a list as the first parameter, 
> and that results in a list return value all the time.
>
> Is this a bug? Should I file a GitHub issue on this? I first encountered 
> this in 1.7.0, but I recently updated to 1.8.0 and it is still present.
>
> Randy
> -- 
> Randy J. Ray - randy.j....@gmail.com - twitter.com/rjray
> Silicon Valley Scale Modelers: http://www.svsm.org
> Sunnyvale, CA
>

-- 
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