Thanks, Lennart. That works, although it took me a few minutes to
figure out why. (For the record, tree-seq returns a copy of its
argument as the first item in the sequence.) This also means that
(flatten "string")
;=> (\s \t \r \i \n \g)
I've put in a patch.
-Stuart Sierra
On Dec 15, 2:45 pm, Lennart Staflin <[email protected]> wrote:
> How about adding a rest around tree-seq:
>
> (defn flatten
> "Takes any nested combination of sequential things (lists, vectors,
> etc.) and returns their contents as a single, flat sequence."
> [x]
> (let [s? #(instance? clojure.lang.Sequential %)]
> (filter (complement s?) (rest (tree-seq s? seq x)))))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---