Your tests aren't testing the interesting part without a doall.
That said, my quick tests with doall show your approach faring even better. :-) Also, I think what my-flatten does with Java arrays is intuitive (and the current flatten not so much).
A patch that preserves the semantics of the existing flatten (except for working with Java arrays) would be welcome.
Thanks!
Stu
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
The full instructions for joining the team and then submitting a patch are at [1] an [2], but in short:
* send in a CA
* join the Assembla space under you real name
* post a patch there linking to this thread
Thanks!
Stu
[1] http://clojure.org/contributing
[2] http://clojure.org/patches
Please submit the modified version, and, if you want, create a separate ticket for "seqable?". I would like to review the latter separately.
Stu
> 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. (See http://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.