On 9 March 2010 22:58, Rick Moynihan <[email protected]> wrote:
> There a parity between this and clojure.contrib.seq-utils/flatten
> (which doesn't work with maps)... So how about this lazy non stack
> consuming alternative?
>
> (defn leaves [m]
> (filter
> (complement map?)
> (rest (tree-seq map? #(vals %)
> m))))
Nice! Another possibility:
(defn leaves [m]
(mapcat (fn f [[k v]]
(if (map? v)
(mapcat f v)
[v]))
m))
Sincerely,
Michał
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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