(at-end? {:keys [context] :as zip})replace element right of the current status
(->> (from-status '[1 [[|]]]) (at-end?)) => true
(->> (from-status '[1 [[[2 |]] 3]]) (at-end?)) => false
replace element right of the current status
(->> (from-status '[1 [[|]]])
(at-end?))
=> true
(->> (from-status '[1 [[[2 |]] 3]])
(at-end?))
=> false(at-inside-most-left? zip)check if at inside-most left point of a container
(-> (from-status '[1 2 [ | 1 2]]) (at-inside-most-left?)) => true
check if at inside-most left point of a container
(-> (from-status '[1 2 [ | 1 2]])
(at-inside-most-left?))
=> true(at-inside-most? zip)check if at inside-most point of a container
(-> (from-status '[1 2 [3 4 |]]) (at-inside-most?)) => true
check if at inside-most point of a container
(-> (from-status '[1 2 [3 4 |]])
(at-inside-most?))
=> true(at-left-most? zip)check if at left-most point of a container
(-> (from-status [1 2 ['| 3 4]]) (at-left-most?)) => true
check if at left-most point of a container
(-> (from-status [1 2 ['| 3 4]])
(at-left-most?))
=> true(at-outside-most? zip)check if at outside-most point of the tree
(-> (from-status [1 2 [3 4 '|]]) (at-outside-most?)) => false
(-> (from-status '[1 2 [3 4 |]]) (step-outside) (step-outside) (at-outside-most?)) => true
check if at outside-most point of the tree
(-> (from-status [1 2 [3 4 '|]])
(at-outside-most?))
=> false
(-> (from-status '[1 2 [3 4 |]])
(step-outside)
(step-outside)
(at-outside-most?))
=> true(at-right-most? zip)check if at right-most point of a container
(-> (from-status '[1 2 [3 4 |]]) (at-right-most?)) => true
check if at right-most point of a container
(-> (from-status '[1 2 [3 4 |]])
(at-right-most?))
=> true(can-step-inside-left? {:keys [context] :as zip})check if can step left inside a container
(-> (from-status '[[3 4] |]) (can-step-inside-left?)) => true
check if can step left inside a container
(-> (from-status '[[3 4] |])
(can-step-inside-left?))
=> true(can-step-inside? {:keys [context] :as zip})check if can step down from current status
(-> (from-status '[1 2 [3 4 |]]) (can-step-inside?)) => false
(-> (from-status '[1 2 | [3 4]]) (can-step-inside?)) => true
check if can step down from current status
(-> (from-status '[1 2 [3 4 |]])
(can-step-inside?))
=> false
(-> (from-status '[1 2 | [3 4]])
(can-step-inside?))
=> true(can-step-left? {:keys [context] :as zip})check if can step left from current status
(-> (from-status '[1 2 [3 | 4]]) (can-step-left?)) => true
(-> (from-status '[1 2 [| 3 4]]) (can-step-left?)) => false
check if can step left from current status
(-> (from-status '[1 2 [3 | 4]])
(can-step-left?))
=> true
(-> (from-status '[1 2 [| 3 4]])
(can-step-left?))
=> false(can-step-outside? {:keys [context] :as zip})check if can step up from current status
(-> (from-status '[1 2 [3 4 |]]) (can-step-outside?)) => true
check if can step up from current status
(-> (from-status '[1 2 [3 4 |]])
(can-step-outside?))
=> true(can-step-right? {:keys [context] :as zip})check if can step right from current status
(-> (from-status '[1 2 [3 | 4]]) (can-step-right?)) => true
(-> (from-status '[1 2 [3 4 |]]) (can-step-right?)) => false
check if can step right from current status
(-> (from-status '[1 2 [3 | 4]])
(can-step-right?))
=> true
(-> (from-status '[1 2 [3 4 |]])
(can-step-right?))
=> false(check-context context)checks that the zipper contains valid functions
(check-context {}) => (throws)
checks that the zipper contains valid functions
(check-context {})
=> (throws)(check-optional context)checks that the meta contains valid functions
(check-optional {}) => (throws)
checks that the meta contains valid functions
(check-optional {})
=> (throws)(current-elements {:keys [left right] :as zip})all elements left and right of current position
(-> (from-status '[1 2 | 3 4]) (current-elements)) => '(1 2 3 4)
(-> (from-status '[1 [2 | 3] 4]) (current-elements)) => '(2 3)
all elements left and right of current position
(-> (from-status '[1 2 | 3 4])
(current-elements))
=> '(1 2 3 4)
(-> (from-status '[1 [2 | 3] 4])
(current-elements))
=> '(2 3)(delete-left {:keys [context left] :as zip})(delete-left {:keys [context] :as zip} n)delete element/s left of the current status
(-> (from-status '[1 2 | 3]) (delete-left) (status)) => '([1 | 3])
delete element/s left of the current status
(-> (from-status '[1 2 | 3])
(delete-left)
(status))
=> '([1 | 3])(delete-right {:keys [context right] :as zip})(delete-right {:keys [context] :as zip} n)delete element/s right of the current status
(-> (from-status '[1 2 | 3]) (delete-right) (status)) => '([1 2 |])
delete element/s right of the current status
(-> (from-status '[1 2 | 3])
(delete-right)
(status))
=> '([1 2 |])(find zip move pred)helper function for the rest of the find series
helper function for the rest of the `find` series
(find-left zip pred)steps status left to search predicate
(-> (from-status '[0 1 [2 3] [4 5] 6 |]) (find-left odd?) (status)) => '([0 | 1 [2 3] [4 5] 6])
(-> (from-status '[0 1 [2 3] [4 5] 6 |]) (find-left keyword?)) => nil
steps status left to search predicate
(-> (from-status '[0 1 [2 3] [4 5] 6 |])
(find-left odd?)
(status))
=> '([0 | 1 [2 3] [4 5] 6])
(-> (from-status '[0 1 [2 3] [4 5] 6 |])
(find-left keyword?))
=> nil(find-next zip pred)step status through the tree in depth first order to the first matching element
(-> (vector-zip [1 [2 [6 7] 3] [4 5]]) (find-next #(= 7 %)) (status)) => '([1 [2 [6 | 7] 3] [4 5]])
(-> (vector-zip [1 [2 [6 7] 3] [4 5]]) (find-next keyword)) => nil
step status through the tree in depth first order to the first matching element
(-> (vector-zip [1 [2 [6 7] 3] [4 5]])
(find-next #(= 7 %))
(status))
=> '([1 [2 [6 | 7] 3] [4 5]])
(-> (vector-zip [1 [2 [6 7] 3] [4 5]])
(find-next keyword))
=> nil(find-prev zip pred)step status through the tree in reverse order to the last matching element
(-> (from-status '[1 [2 [6 | 7] 3] [4 5]]) (find-prev even?) (status)) => '([1 [2 [| 6 7] 3] [4 5]])
step status through the tree in reverse order to the last matching element
(-> (from-status '[1 [2 [6 | 7] 3] [4 5]])
(find-prev even?)
(status))
=> '([1 [2 [| 6 7] 3] [4 5]])(find-right zip pred)steps status right to search for predicate
(-> (from-status '[0 | 1 [2 3] [4 5] 6]) (find-right even?) (status)) => '([0 1 [2 3] [4 5] | 6])
steps status right to search for predicate
(-> (from-status '[0 | 1 [2 3] [4 5] 6])
(find-right even?)
(status))
=> '([0 1 [2 3] [4 5] | 6])(from-status data)(from-status data zipper-fn)returns a zipper given a data structure with | as the status
(from-status '[1 2 3 | 4]) => (contains {:left '(3 2 1), :right '(4)})
returns a zipper given a data structure with | as the status
(from-status '[1 2 3 | 4])
=> (contains {:left '(3 2 1),
:right '(4)})(get zip)(get zip arg)(get zip func step)gets the value of the zipper
(-> (vector-zip [0 1 2 3 4]) (step-inside) (get)) => 0
gets the value of the zipper
(-> (vector-zip [0 1 2 3 4])
(step-inside)
(get))
=> 0(hierarchy {:keys [context] :as zip})replace element right of the current status
(->> (from-status '[1 [[|]]]) (hierarchy) (map right-element)) => [[] [[]] [1 [[]]]]
replace element right of the current status
(->> (from-status '[1 [[|]]])
(hierarchy)
(map right-element))
=> [[] [[]] [1 [[]]]](insert-left {:keys [context] :as zip} data)(insert-left {:keys [context] :as zip} data & more)insert element/s left of the current status
(-> (from-status '[1 2 [[| 3] 4]]) (insert-left 1 2 3) (status)) => '([1 2 [[1 2 3 | 3] 4]])
insert element/s left of the current status
(-> (from-status '[1 2 [[| 3] 4]])
(insert-left 1 2 3)
(status))
=> '([1 2 [[1 2 3 | 3] 4]])(insert-right {:keys [context] :as zip} data)(insert-right {:keys [context] :as zip} data & more)insert element/s right of the current status
(-> (from-status '[| 1 2 3]) (insert-right 1 2 3) (status)) => '([| 3 2 1 1 2 3])
insert element/s right of the current status
(-> (from-status '[| 1 2 3])
(insert-right 1 2 3)
(status))
=> '([| 3 2 1 1 2 3])(is zip pred)(is zip pred step)checks zip given a predicate
(-> (vector-zip [0 1 2 3 4]) (step-inside) (is zero?)) => true
checks zip given a predicate
(-> (vector-zip [0 1 2 3 4])
(step-inside)
(is zero?))
=> true(is-container? zip)(is-container? {:keys [context] :as zip} step)checks if node on either side is a container
(-> (vector-zip [1 2 3]) (is-container? :right)) => true
(-> (vector-zip [1 2 3]) (is-container? :left)) => false
checks if node on either side is a container
(-> (vector-zip [1 2 3])
(is-container? :right))
=> true
(-> (vector-zip [1 2 3])
(is-container? :left))
=> false(is-empty-container? zip)(is-empty-container? {:keys [context] :as zip} step)check if current container is empty
(-> (vector-zip []) (is-empty-container?)) => true
check if current container is empty
(-> (vector-zip [])
(is-empty-container?))
=> true(left-element zip)element directly left of current position
(-> (vector-zip [1 2 3 4]) (step-inside))
(-> (from-status '[1 2 3 | 4]) (left-element)) => 3
element directly left of current position
(-> (vector-zip [1 2 3 4])
(step-inside))
(-> (from-status '[1 2 3 | 4])
(left-element))
=> 3(left-elements zip)all elements left of current position
(-> (from-status '[1 2 | 3 4]) (left-elements)) => '(1 2)
all elements left of current position
(-> (from-status '[1 2 | 3 4])
(left-elements))
=> '(1 2)(levelwalk zip [pred] f)(levelwalk zip [pred] f levelwalk {:keys [move-right can-move-right?] :as opts})performs a match at the same level
(-> (vector-zip [1 2 3 4]) (step-inside) (levelwalk [(fn [zip] (odd? (right-element zip)))] delete-right) (root-element)) => [2 4]
performs a match at the same level
(-> (vector-zip [1 2 3 4])
(step-inside)
(levelwalk [(fn [zip]
(odd? (right-element zip)))]
delete-right)
(root-element))
=> [2 4](list-child-elements zip)(list-child-elements {:keys [context] :as zip} direction)lists elements of a container
(-> (vector-zip [1 2 3]) (list-child-elements :right)) => '(1 2 3)
(-> (vector-zip 1) (list-child-elements :right)) => (throws)
lists elements of a container
(-> (vector-zip [1 2 3])
(list-child-elements :right))
=> '(1 2 3)
(-> (vector-zip 1)
(list-child-elements :right))
=> (throws)(matchwalk zip matchers f)(matchwalk zip
[pred & more :as matchers]
f
matchwalk
{:keys [move-right can-move-right?] :as opts})performs a match at each level
(-> (matchwalk (vector-zip [1 [2 [3 [4]]]]) [(fn [zip] (= 2 (first (right-element zip)))) (fn [zip] (= 4 (first (right-element zip))))] delete-left) (root-element)) => [1 [2 [[4]]]]
performs a match at each level
(-> (matchwalk (vector-zip [1 [2 [3 [4]]]])
[(fn [zip]
(= 2 (first (right-element zip))))
(fn [zip]
(= 4 (first (right-element zip))))]
delete-left)
(root-element))
=> [1 [2 [[4]]]](postwalk zip f)emulates clojure.walk/postwalk behavior with zipper
(-> (vector-zip [[1 2] [3 4]]) (postwalk (fn [v] (if (vector? v) (conj v 100) (+ v 100)))) (root-element)) => [[101 102 100] [103 104 100] 100]
emulates clojure.walk/postwalk behavior with zipper
(-> (vector-zip [[1 2] [3 4]])
(postwalk (fn [v] (if (vector? v)
(conj v 100)
(+ v 100))))
(root-element))
=> [[101 102 100] [103 104 100] 100](prewalk {:keys [context] :as zip} f)emulates clojure.walk/prewalk behavior with zipper
(-> (vector-zip [[1 2] [3 4]]) (prewalk (fn [v] (if (vector? v) (conj v 100) (+ v 100)))) (root-element)) => [[101 102 200] [103 104 200] 200]
emulates clojure.walk/prewalk behavior with zipper
(-> (vector-zip [[1 2] [3 4]])
(prewalk (fn [v] (if (vector? v)
(conj v 100)
(+ v 100))))
(root-element))
=> [[101 102 200] [103 104 200] 200](replace-left zip data)replace element left of the current status
(-> (from-status '[1 2 | 3]) (replace-left "10") (status)) => '([1 "10" | 3])
replace element left of the current status
(-> (from-status '[1 2 | 3])
(replace-left "10")
(status))
=> '([1 "10" | 3])(replace-right zip data)replace element right of the current status
(-> (from-status '[1 2 | 3]) (replace-right "10") (status)) => '([1 2 | "10"])
replace element right of the current status
(-> (from-status '[1 2 | 3])
(replace-right "10")
(status))
=> '([1 2 | "10"])(right-element zip)element directly right of current position
(-> (from-status '[1 2 3 | 4]) (right-element)) => 4
element directly right of current position
(-> (from-status '[1 2 3 | 4])
(right-element))
=> 4(right-elements zip)all elements right of current position
(-> (from-status '[1 2 | 3 4]) (right-elements)) => '(3 4)
all elements right of current position
(-> (from-status '[1 2 | 3 4])
(right-elements))
=> '(3 4)(root-element zip)accesses the top level node
(-> (vector-zip [[[3] 2] 1]) (step-inside-most) (root-element)) => [[[3] 2] 1]
accesses the top level node
(-> (vector-zip [[[3] 2] 1])
(step-inside-most)
(root-element))
=> [[[3] 2] 1](seq-zip root)(seq-zip root opts)constructs a sequence zipper
(seq-zip '(1 2 3 4 5)) => (contains {:left (), :right '((1 2 3 4 5))})
constructs a sequence zipper
(seq-zip '(1 2 3 4 5))
=> (contains {:left (),
:right '((1 2 3 4 5))})(status {:keys [context] :as zip})returns the form with the status showing
(-> (vector-zip [1 [[2] 3]]) (step-inside) (step-right) (step-inside) (step-inside) (status)) => '([1 [[| 2] 3]])
returns the form with the status showing
(-> (vector-zip [1 [[2] 3]])
(step-inside)
(step-right)
(step-inside)
(step-inside)
(status))
=> '([1 [[| 2] 3]])(status-string zip)returns the string form of the status
(-> (vector-zip [1 [[2] 3]]) (step-inside) (step-right) (status-string)) => "[1 | [[2] 3]]"
returns the string form of the status
(-> (vector-zip [1 [[2] 3]])
(step-inside)
(step-right)
(status-string))
=> "[1 | [[2] 3]]"(step-end {:keys [context] :as zip})steps status to container directly at end
(->> (from-status '[1 | [[]]]) (step-end) (status)) => '([1 [[|]]])
steps status to container directly at end
(->> (from-status '[1 | [[]]])
(step-end)
(status))
=> '([1 [[|]]])(step-inside {:keys [context] :as zip})(step-inside zip n)step down from current status
(-> (from-status '[1 2 | [3 4]]) (step-inside) (status)) => '([1 2 [| 3 4]])
step down from current status
(-> (from-status '[1 2 | [3 4]])
(step-inside)
(status))
=> '([1 2 [| 3 4]])(step-inside-left {:keys [context] :as zip})(step-inside-left zip n)steps into the form on the left side
(-> (from-status '[[1 2] |]) (step-inside-left) (status)) => '([[1 2 |]])
steps into the form on the left side
(-> (from-status '[[1 2] |])
(step-inside-left)
(status))
=> '([[1 2 |]])(step-inside-most {:keys [context] :as zip})step to at-inside-most point of current container
(-> (from-status '[1 2 | [[3] 4]]) (step-inside-most) (status)) => '([1 2 [[| 3] 4]])
step to at-inside-most point of current container
(-> (from-status '[1 2 | [[3] 4]])
(step-inside-most)
(status))
=> '([1 2 [[| 3] 4]])(step-inside-most-left {:keys [context] :as zip})steps all the way inside to the left side
(-> (from-status '[[1 [2]] | 3 4]) (step-inside-most-left) (status)) => '([[1 [2 |]] 3 4])
steps all the way inside to the left side
(-> (from-status '[[1 [2]] | 3 4])
(step-inside-most-left)
(status))
=> '([[1 [2 |]] 3 4])(step-left {:keys [left context right] :as zip})(step-left zip n)step left from current status
(-> (from-status '[1 2 [3 4 |]]) (step-left) (status)) => '([1 2 [3 | 4]])
step left from current status
(-> (from-status '[1 2 [3 4 |]])
(step-left)
(status))
=> '([1 2 [3 | 4]])(step-left-most {:keys [context] :as zip})step to left-most point of current container
(-> (from-status '[1 2 [3 4 |]]) (step-left-most) (status)) => '([1 2 [| 3 4]])
step to left-most point of current container
(-> (from-status '[1 2 [3 4 |]])
(step-left-most)
(status))
=> '([1 2 [| 3 4]])(step-next {:keys [context] :as zip})step status through the tree in depth first order
(->> (from-status '[| 1 [2 [6 7] 3] [4 5]]) (iterate step-next) (take-while identity) (map right-element)) => '(1 [2 [6 7] 3] 2 [6 7] 6 7 3 [4 5] 4 5)
step status through the tree in depth first order
(->> (from-status '[| 1 [2 [6 7] 3] [4 5]])
(iterate step-next)
(take-while identity)
(map right-element))
=> '(1 [2 [6 7] 3] 2 [6 7] 6 7 3 [4 5] 4 5)(step-outside zip)(step-outside zip n)step out to the current container
(-> (from-status '[1 2 [| 3 4]]) (step-outside) (status)) => '([1 2 | [3 4]])
step out to the current container
(-> (from-status '[1 2 [| 3 4]])
(step-outside)
(status))
=> '([1 2 | [3 4]])(step-outside-most {:keys [context] :as zip})step to outside-most point of the tree
(-> (from-status '[1 2 [| 3 4]]) (step-outside-most) (status)) => '(| [1 2 [3 4]])
step to outside-most point of the tree
(-> (from-status '[1 2 [| 3 4]])
(step-outside-most)
(status))
=> '(| [1 2 [3 4]])(step-outside-most-right {:keys [context] :as zip})step to outside-most point of the tree to the right
(-> (from-status '[1 2 [| 3 4]]) (step-outside-most-right) (status)) => '([1 2 [3 4]] |)
step to outside-most point of the tree to the right
(-> (from-status '[1 2 [| 3 4]])
(step-outside-most-right)
(status))
=> '([1 2 [3 4]] |)(step-outside-right zip)(step-outside-right zip n)the right of the current container
(-> (from-status '[1 2 [| 3 4]]) (step-outside-right) (status)) => '([1 2 [3 4] |])
the right of the current container
(-> (from-status '[1 2 [| 3 4]])
(step-outside-right)
(status))
=> '([1 2 [3 4] |])(step-prev {:keys [context] :as zip})step status in reverse through the tree in depth first order
(->> (from-status '[1 [2 [6 7] 3] [4 | 5]]) (iterate step-prev) (take 10) (map right-element)) => '(5 4 [4 5] 3 7 6 [6 7] 2 [2 [6 7] 3] 1)
step status in reverse through the tree in depth first order
(->> (from-status '[1 [2 [6 7] 3] [4 | 5]])
(iterate step-prev)
(take 10)
(map right-element))
=> '(5 4 [4 5] 3 7 6 [6 7] 2 [2 [6 7] 3] 1)(step-right {:keys [left right context] :as zip})(step-right zip n)step right from current status
(-> (from-status '[1 2 [| 3 4]]) (step-right) (status)) => '([1 2 [3 | 4]])
step right from current status
(-> (from-status '[1 2 [| 3 4]])
(step-right)
(status))
=> '([1 2 [3 | 4]])(step-right-most {:keys [context] :as zip})step to right-most point of current container
(-> (from-status '[1 2 [| 3 4]]) (step-right-most) (status)) => '([1 2 [3 4 |]])
step to right-most point of current container
(-> (from-status '[1 2 [| 3 4]])
(step-right-most)
(status))
=> '([1 2 [3 4 |]])(surround {:keys [context parent left] :as zip})nests elements in current block within another container
(-> (vector-zip 3) (insert-left 1 2) (surround) (status)) => '(| [1 2 3])
(->> (from-status '[1 [1 2 | 3 4]]) (surround) (status)) => '([1 [| [1 2 3 4]]])
nests elements in current block within another container
(-> (vector-zip 3)
(insert-left 1 2)
(surround)
(status))
=> '(| [1 2 3])
(->> (from-status '[1 [1 2 | 3 4]])
(surround)
(status))
=> '([1 [| [1 2 3 4]]])(update-child-elements zip child-elements)(update-child-elements {:keys [context] :as zip} child-elements direction)updates elements of a container
(-> (vector-zip [1 2]) (update-child-elements [1 2 3 4] :right) (right-element)) => [1 2 3 4]
updates elements of a container
(-> (vector-zip [1 2])
(update-child-elements [1 2 3 4] :right)
(right-element))
=> [1 2 3 4](vector-zip root)(vector-zip root opts)constructs a vector based zipper
(vector-zip [1 2 3 4 5]) => (contains {:left (), :right '([1 2 3 4 5])})
constructs a vector based zipper
(vector-zip [1 2 3 4 5])
=> (contains {:left (),
:right '([1 2 3 4 5])})(zipper root context)(zipper root context opts)constructs a zipper
constructs a zipper
(zipper? x)checks to see if an object is a zipper
(zipper? 1) => false
checks to see if an object is a zipper (zipper? 1) => false
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |