Hi Dave,
I don't know if there is the one true way of representing a tree as a
vector, but clojure.zip allows you to zip over pretty much any structure
you like, as long as you provide the right functions. The zipper
function is a bit like an informal protocol in that way.
The built-in vector-zip
Dave,
Your first attempt looks OK to me.
(require '(clojure [zip :as z]))
(def zipper (z/vector-zip [:A [:B [:D :E]] [:C [:F :G]]]))
(defn pre-order [loc]
(when-not (z/end? loc)
(when-not (z/branch? loc)
(println (z/node loc)))
(recur (z/next loc
user=> (pre-order zipper)
: