On Tue, Mar 22, 2011 at 5:08 AM, Shantanu Kumar
<kumar.shant...@gmail.com> wrote:
> On Mar 22, 1:15 pm, Sunil S Nandihalli <sunil.nandiha...@gmail.com>
> wrote:
>> Hello everybody,
>>  I was wondering why there is no 1 argument version of conj and disj. I
>> think that would be very convenient. Especially when used in the following
>> way
>>
>> (apply conj some-collection collection-of-elements-to-be-conjed)
>>
>> Currently the above usage would fail for both conj and disj when the
>> collection of elements to be conjed is empty . So, I need to check if the
>> collection is empty and use appropriately.. but just thought having conj and
>> disj just return the original collection when there are no keys to be conjed
>> or disjed would be very convenient
>>
>> May be I should be using something else .. I would like to what that other
>> function is.
>
> Maybe these:
> user=> (reduce conj [] [1 2 3 4])
> [1 2 3 4]
> user=> (reduce disj #{1 2 3 4} [1 2 3 4])
> #{}
>
> Is that what you were looking for?

(into existing-coll coll-of-new-elements) works as well; and on my
copy of 1.2, (apply disj #{1 2 3 4} []) works. (Thus making the
failure of (apply conj x []) seem all the stranger.)

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

Reply via email to