As David was posting his code, I was wrapping up my own experimentation
with how transients apply here. Mine is similar, but doesn't use pattern
matching -- seems a bit faster:
(defrecord Tree [h l r])
(defn generate-tree [c]
(when-let [s (seq c)]
(let [lr (generate-tree (rest s))]
(Tree. (first s) lr lr))))
(defn to-list
([t] (persistent! (to-list t (transient []))))
([t b]
(if t
(let [b (to-list (:l t) b),
b (conj! b (:h t)),
b (to-list (:r t) b)]
b)
b)))
--
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