Hi,
This is pretty strange behavior to me, why is the case that keys
function don't return a set like java?
That could lead to a big penalty in performance if you don't realize
this difference.

I don't say that this is bug, although I would like to believe that a
nice explanation exists ;-)
Regards,
-- 
Bauna


On 07/01/2013 03:25 PM, Jim - FooBar(); wrote:
> HI there,
>
> It's pretty obvious what is happening....you are not providing sets to
> union but rather seqs. in other words 'keys' return a seq not a set.
> union will simply conj all the elements from the first set into the
> second (or vice versa). if they are not sets they won't behave like
> sets...
>
> in order to get what you want  you need:
>
> (clojure.set/union (set (keys {:a 1 :b 2 :c 3})) (set (keys {:a 1 :b 2
> :c 3})))
>
> hope that helps,
>
> Jim
>
>
> On 01/07/13 19:05, Goldritter wrote:
>> I wanted to create a union of the keys from two maps.
>>
>> When I write
>> (clojure.set/union (keys {:a 1 :b 2 :c 3}) (keys {:a 1 :b 2 :c 3}))
>> I get a result of (:b :c :a :a :c :b).
>> When I write (set (clojure.set/union (keys {:a 1 :b 2 :c 3}) (keys
>> {:a 1 :b 2 :c 3})))
>> the result is #{:a :c :b}.
>>
>> The document of clojure.set/union describes that the function "Return
>> a set that is the union of the input sets".
>> As it seems the function keys does not return a set and so the
>> returning result is not a set too. Correct?
>> And that this is the reason, that the keys are duplicated in the
>> returning "list".
>>
>> I wonder know is this is a bug or not. And what the normal behaviour
>> of the function should be in this case?
>> Should it throw an Exception, because the passed parameters are not
>> sets, should it return a set, even if the passed parameters are no
>> sets or should the desciption of the function should be changed to
>> express that a list (with eeventually duplicated entries) is
>> returend, if the passed parameters are lists?
>>
>> -- 
>> -- 
>> 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