Created
January 24, 2012 15:41
-
-
Save anonymous/1670753 to your computer and use it in GitHub Desktop.
global zipper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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