It would be nice if clojure.core/conj had a unary implementation
([coll] coll)
The motivating use case is when one is conjoining sequences of
items to a collection all at once:
(apply conj coll seqable)
such as (apply conj #{1 2 3} [2 4 6 8 10]).
Currently (1.4.0), this will raise an arity exception
if the seqable object is empty:
(apply conj #{1 2 3} [])
necessitating an awkward empty? check when,
for instance, the sequence is computed or passed in.
It seems to me that making unary conj the identity is both
a natural interpretation and essentially cost free, while
making this use case much more convenient.
Moreover, it is consistent with clojure.core/disj for sets
which does act like this
(apply disj #{1 2 3} []) -> #{1 2 3}
and has an identity unary implementation.
Comments?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en