How could I create the following graph using Clojure Zipper (vector-zip
):
A
/ | \
B C D
/ \
E F
I have tried
(vector-zip ["A" ["B" "C" "D"["E" "F"]] ])
It returns
[["A" ["B" "C" "D" ["E" "F"]]] nil]
Is it right?
Yes it's right. Some tests of your code:
(require '[clojure.zip :as zip])
(def zv (zip/vector-zip ["A" ["B" "C" "D"["E" "F"]]]))
(-> zv zip/next) ; => ["A" {:l [], :pnodes [["A" ["B" "C" "D" ["E" "F"]]]], :ppath nil, :r (["B" "C" "D" ["E" "F"]])}]
(-> zv zip/next zip/node) ; => "A"
(-> zv zip/next zip/next zip/next zip/node) ; => "B"
(-> zv zip/next zip/next zip/children) ; => ("B" "C" "D" ["E" "F"])