RosettaCodeData/Task/Same-fringe/Clojure/same-fringe-1.clj

10 lines
311 B
Clojure
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(defn fringe-seq [branch? children content tree]
(letfn [(walk [node]
(lazy-seq
(if (branch? node)
(if (empty? (children node))
(list (content node))
(mapcat walk (children node)))
(list node))))]
(walk tree)))