You're right about rest, I didn't see that rest should be preferred to
next when consuming seqs in this style.

I agree that flatten returning the empty list for some of the things
that actually can be "seqed" is odd. I'm sure there's a good reason
somewhere, but it's not to hard to change by just using seqable? from
contrib. That makes flatten handle anything. After benchmarking it
though, it seems like its muuuch slower; so slow that I got bored of
waiting after 5 minutes. Seems like a punt though :/


On Jul 14, 3:55 pm, Steve Miner <stevemi...@gmail.com> wrote:
> On Jul 14, 2010, at 2:40 PM, Cam wrote:
>
> > I definitely like this version a little better. If you change the else
> > of the if to be just (list), it returns the empty list just as core/
> > flatten does. Mind if I update the ticket with this patch?
>
> It's all yours.  Really, just a slight change from your code anyway.
>
> I wonder about the call to next.  I'm thinking it should be rest instead.  
> (Seehttp://clojure.org/lazy)
>
> I definitely don't like the way (flatten 10)  and (flatten {:a 1 :b 2}) 
> return the empty list (in 1.2 beta).  I think these are accidents, and I 
> worry that they will obscure higher-level bugs.
>
> My preference is to return the arg if it's not sequential? as I believe it 
> will provide a more useful result at no extra cost.  In that case, the 
> argument to flatten was probably a mistake, and it's better if the value 
> shows up somewhere rather than being mysteriously swallowed.  On the other 
> hand, it might make sense to return (list arg) on the theory that flatten 
> should always return a seq.  I could live with that.

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