repl> (-> root zip/down zip/right)
[{:answer-keys [5 6], :id 3} {:l [{:id 2, :answer-keys []}], :pnodes [{:answer-keys [2 3 4], :id 1}], :ppath nil, :r ({:answer-keys [7], :id 4})}]
I see this data when I print out the zipper on the repl. I am thinking that this may be all the data I would need to serialize a zipper? Is it possible to de-serialize a zipper from the provided data?
I am looking for something like the zip/serialize and zip/deserialize function imagined below.
(def s (zip/serialize (-> root zip/down zip/right))) ;; s is a string
(def d (zip/deserialize s)) ;; d is a zipper location
;;And I can go on using the deserialized zipper d without any difficulty.
Does anyone know how to do this?
the magic of zippers is they are a data structure that represents everything needed to produce arbitrarily modified versions of tree structures. zippers print and read just fine because they are proper values and don’t require any state
you can “serialize” it with
pr-strand “deserialize” it withreadmake a zipper:
serialize it to a string:
read it back:
do something with the result: