(defn flatten-nodes-coll [x]
(letfn [(flat* [x stack]
(if (node? x)
(cons x (when (seq stack) (flat (peek stack) (pop stack))))
(if-let [[x & xs] (seq x)]
(recur x (conj stack xs))
(when (seq stack)
(recur (peek stack) (pop stack))))))
(flat [x stack]
(lazy-seq (flat* x stack)))]
(flat x ())))
Comments top
No comments for flatten-nodes-coll. Log in to add a comment.