rewrite-clj 2024-05-21

is there an equivalent to tree-seq or the zipper api?

I typically reach for zippers when tree-seq is not enough but you could easily write

(defn zipseq
  [z]
  (lazy-seq
    (cons (z/node z)
          (when-let [zn (z/next z)]
            (zipseq zn)))))

This kind of defeats the purpose of zippers, you can build such a tree-seq entirely without zippers too

lol my goal was to test how much time it takes to traverse the different representations of a file of clojure code

Shouldn’t be hard to write yourself

probably not, no, i'm just doing some performance testing and didn't want to dive into using the zipper api if it's too slow for my current needs

Oh zipper API, I thought just the Node stuff. How would a tree-seq on a zipper make sense?

lol it might not! i'm very unfamiliar with it, so i'm just experimenting at the moment.

I think I know what you might be getting at though. There is z/next to iterate through all the nodes

you don't have to build one for me, i don't think i'm going to end up using the zipper api in any real way