Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2012 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1670753 to your computer and use it in GitHub Desktop.
Save anonymous/1670753 to your computer and use it in GitHub Desktop.
global zipper
(def global-list (atom []))
(defn zip-create [xs]
(do
(reset! global-list xs)
[0 (first xs) xs]))
(defn zip-assoc [[index head v] element]
(let [new-vec (assoc v index element)]
(reset! global-list new-vec)
[index element new-vec]))
(defn zip-head [[_ head _2]]
head)
(defn zip-next [[index head v]]
[(inc index) (nth v (inc index)) v])
(defn zip-prev [[index head v]]
[(dec index) (nth v (dec index)) v])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment