2011/1/17 Stuart Sierra <the.stuart.sie...@gmail.com> > The problem with a "seq-able?" predicate is that the definition of what is > seq-able is often context-dependent. `seq` works on Strings, but you > probably don't want `flatten` to turn a String into a sequence of > characters. > > Good point. There is no static atom/listp distinction in Clojure. Still a predicate function for "can yield a seq" is missing, to provide a flexible flatten implementation like:
(defn my-flatten ([pred coll] (mapcat (fn [p] (if (pred (first p)) (mapcat my-flatten p) p)) (partition-by pred coll))) ([coll] (my-flatten sequential? coll))) Jürgen -- 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