Paul, I already gave a minimal example of the code it makes simpler, i.e. work in the first place:
(apply interleave some-colls) I ran into this a couple of times, and wrote my own variant of interleave that handles the one-coll case. I'd rather see this case handled by interleave. How often do you do: (+ 5) or (* 3) ? But you might have used something like (apply + coll) or (reduce + coll) and under certain circumstances your coll might have had only one element. Still + works just fine and returns a value that makes sense (it even does if you call it with no argument). I'm basically asking to get the same case that clojure handles for a lot of other functions added to "interleave". Eugen On May 29, 7:07 pm, Paul Hobbs <paul_ho...@hmc.edu> wrote: > What code would this make simpler? Are you constantly having to check this > > (apply interleave some-colls) > special case? If not, I don't see a reason to include it. > -- > Paul Hobbs > > On Sat, May 29, 2010 at 1:32 AM, Eugen Dück <eu...@dueck.org> wrote: > > When I do > > > (apply interleave some-colls) > > > and some-colls is a sequence/collection of only one sequence/ > > collection, it will throw: > > > user=> (apply interleave [[1 2]]) > > java.lang.IllegalArgumentException: Wrong number of args passed to: > > core$interleave (NO_SOURCE_FILE:0) > > > (Of course I don't need the apply to cause that exception, but calling > > interleave directly with just one parameter doesn't make any sense. > > But in the case you use apply, having only one sequence in a sequence > > is a possible corner case that can arise "at run time") > > > In order to make interleave more general, I'd like to add a "one param > > overload" to interleave like > > > (defn interleave > > "Returns a lazy seq of the first item in each coll, then the second > > etc." > > ([c] (seq c)) > > ... > > > or even just > > > (defn interleave > > ([c] c) > > > but that would break the contract of interleave, in that it returns > > whatever you pass in, which might not be a sequence, as is the case in > > my example. > > > Any thoughts on this? > > > Eugen > > > -- > > 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<clojure%2bunsubscr...@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 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