Liking cljdoc? Tell your friends :D

hara.zip


bottom-most?clj

(bottom-most? zip)

check if at bottom-most point of a branch

(-> (zip/from-cursor '[1 2 [3 4 |]]) (bottom-most?)) => true

check if at bottom-most point of a branch

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (bottom-most?))
=> true
raw docstring

cursorclj

(cursor zip)

returns the form with the cursor showing

(-> (vector-zip [1 [[2] 3]]) (find-next even?) (cursor)) => '([1 [[| 2] 3]])

returns the form with the cursor showing

(-> (vector-zip [1 [[2] 3]])
    (find-next even?)
    (cursor))
=> '([1 [[| 2] 3]])
raw docstring

cursor-strclj

(cursor-str zip)

returns the string form of the cursor

(-> (vector-zip [1 [[2] 3]]) (find-next even?) (cursor-str)) => "[1 [[| 2] 3]]"

returns the string form of the cursor

(-> (vector-zip [1 [[2] 3]])
    (find-next even?)
    (cursor-str))
=> "[1 [[| 2] 3]]"
raw docstring

delete-leftclj

(delete-left {:keys [left] :as zip})
(delete-left zip num)

delete element/s left of the current position

(-> (zip/from-cursor '[1 2 | 3]) (delete-left) (zip/cursor)) => '([1 | 3])

delete element/s left of the current position

(-> (zip/from-cursor '[1 2 | 3])
    (delete-left)
    (zip/cursor))
=> '([1 | 3])
raw docstring

delete-rightclj

(delete-right {:keys [right] :as zip})
(delete-right zip num)

delete element/s right of the current position

(-> (zip/from-cursor '[1 2 | 3]) (delete-right) (zip/cursor)) => '([1 2 |])

delete element/s right of the current position

(-> (zip/from-cursor '[1 2 | 3])
    (delete-right)
    (zip/cursor))
=> '([1 2 |])
raw docstring

downclj

(down zip)

move cursor down

(-> (from-cursor '[1 [| [2] 3]]) (down) (cursor)) => '([1 [[| 2] 3]])

move cursor down

(-> (from-cursor '[1 [| [2] 3]])
    (down)
    (cursor))
=> '([1 [[| 2] 3]])
raw docstring

endclj

(end zip)

move cursor to the end of the tree (->> (vector-zip [1 [2 [6 7] 3] [4 5]]) (end) (cursor)) => '([1 [2 [6 7] 3] [4 | 5]])

move cursor to the end of the tree
(->> (vector-zip [1 [2 [6 7] 3] [4 5]])
     (end)
     (cursor))
=> '([1 [2 [6 7] 3] [4 | 5]])
raw docstring

find-nextclj

(find-next zip pred)

move cursor through the tree in depth first order to the first matching element

(-> (vector-zip [1 [2 [6 7] 3] [4 5]]) (find-next #(= 7 %)) (cursor)) => '([1 [2 [6 | 7] 3] [4 5]])

move cursor through the tree in depth first order to the first matching element

(-> (vector-zip [1 [2 [6 7] 3] [4 5]])
    (find-next #(= 7 %))
    (cursor))
=> '([1 [2 [6 | 7] 3] [4 5]])
raw docstring

find-prevclj

(find-prev zip pred)

move cursor through the tree in reverse order to the last matching element

(-> (from-cursor '[1 [2 [6 | 7] 3] [4 5]]) (find-prev even?) (cursor)) => '([1 [2 [| 6 7] 3] [4 5]])

move cursor through the tree in reverse order to the last matching element

(-> (from-cursor '[1 [2 [6 | 7] 3] [4 5]])
    (find-prev even?)
    (cursor))
=> '([1 [2 [| 6 7] 3] [4 5]])
raw docstring

from-cursorclj

(from-cursor arr)

returns a zipper given a data structure with | as the cursor

(from-cursor '[1 2 3 | 4]) => (contains {:left '(3 2 1), :right '(4)})

returns a zipper given a data structure with | as the cursor

(from-cursor '[1 2 3 | 4])
=> (contains {:left '(3 2 1),
              :right '(4)})
raw docstring

historyclj

(history zip)

accesses the zipper history

(-> (vector-zip [1 [2 3]]) (move-down) (move-right) (history)) => [[:down] [:right]]

accesses the zipper history

(-> (vector-zip [1 [2 3]])
    (move-down)
    (move-right)
    (history))
=> [[:down] [:right]]
raw docstring

insert-leftclj

(insert-left zip element)
(insert-left zip element & more)

insert element/s left of the current position

(-> (zip/from-cursor '[1 2 [[| 3] 4]]) (insert-left 1 2 3) (zip/cursor)) => '([1 2 [[1 2 3 | 3] 4]])

insert element/s left of the current position

(-> (zip/from-cursor '[1 2  [[| 3] 4]])
    (insert-left 1 2 3)
    (zip/cursor))
=> '([1 2 [[1 2 3 | 3] 4]])
raw docstring

insert-rightclj

(insert-right zip element)
(insert-right zip element & more)

insert element/s right of the current position

(-> (zip/from-cursor '[| 1 2 3]) (insert-right 1 2 3) (zip/cursor)) => '([| 3 2 1 1 2 3])

insert element/s right of the current position

(-> (zip/from-cursor '[| 1 2 3])
    (insert-right 1 2 3)
    (zip/cursor))
=> '([| 3 2 1 1 2 3])
raw docstring

leftclj

(left zip)

move cursor left

(-> (from-cursor [1 '| 2 3]) (left) (cursor)) => '([| 1 2 3])

move cursor left

(-> (from-cursor [1 '| 2 3])
    (left)
    (cursor))
=> '([| 1 2 3])
raw docstring

left-most?clj

(left-most? zip)

check if at left-most point of a branch

(-> (zip/from-cursor [1 2 ['| 3 4]]) (left-most?)) => true

check if at left-most point of a branch

(-> (zip/from-cursor [1 2 ['| 3 4]])
    (left-most?))
=> true
raw docstring

left-nodeclj

(left-node zip)

element directly left of current position

(-> (zip/from-cursor '[1 2 3 | 4]) (left-node)) => 3

element directly left of current position

(-> (zip/from-cursor '[1 2 3 | 4])
    (left-node))
=> 3
raw docstring

left-nodesclj

(left-nodes zip)

all elements left of current position

(-> (zip/from-cursor '[1 2 | 3 4]) (left-nodes)) => '(1 2)

all elements left of current position

(-> (zip/from-cursor '[1 2 | 3 4])
    (left-nodes))
=> '(1 2)
raw docstring

move-bottom-mostclj

(move-bottom-most zip)

move to bottom-most point of current branch

(-> (zip/from-cursor '[1 2 | [[3] 4]]) (move-bottom-most) (zip/cursor)) => '([1 2 [[| 3] 4]])

move to bottom-most point of current branch

(-> (zip/from-cursor '[1 2 | [[3] 4]])
    (move-bottom-most)
    (zip/cursor))
=> '([1 2 [[| 3] 4]])
raw docstring

move-downclj

(move-down zip)
(move-down zip num)

move down from current position

(-> (zip/from-cursor '[1 2 | [3 4]]) (move-down) (zip/cursor)) => '([1 2 [| 3 4]])

move down from current position

(-> (zip/from-cursor '[1 2 | [3 4]])
    (move-down)
    (zip/cursor))
=> '([1 2 [| 3 4]])
raw docstring

move-down?clj

(move-down? zip)

check if can move down from current position

(-> (zip/from-cursor '[1 2 [3 4 |]]) (move-down?)) => false

(-> (zip/from-cursor '[1 2 | [3 4]]) (move-down?)) => true

check if can move down from current position

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (move-down?))
=> false

(-> (zip/from-cursor '[1 2 | [3 4]])
    (move-down?))
=> true
raw docstring

move-leftclj

(move-left {:keys [left right] :as zip})
(move-left zip num)

move left from current position

(-> (zip/from-cursor '[1 2 [3 4 |]]) (move-left) (zip/cursor)) => '([1 2 [3 | 4]])

move left from current position

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (move-left)
    (zip/cursor))
=> '([1 2 [3 | 4]])
raw docstring

move-left-mostclj

(move-left-most zip)

move to left-most point of current branch

(-> (zip/from-cursor '[1 2 [3 4 |]]) (move-left-most) (zip/cursor)) => '([1 2 [| 3 4]])

move to left-most point of current branch

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (move-left-most)
    (zip/cursor))
=> '([1 2 [| 3 4]])
raw docstring

move-left?clj

(move-left? zip)

check if can move left from current position

(-> (zip/from-cursor '[1 2 [3 | 4]]) (move-left?)) => true

(-> (zip/from-cursor '[1 2 [| 3 4]]) (move-left?)) => false

check if can move left from current position

(-> (zip/from-cursor '[1 2 [3 | 4]])
    (move-left?))
=> true

(-> (zip/from-cursor '[1 2 [| 3 4]])
    (move-left?))
=> false
raw docstring

move-rightclj

(move-right {:keys [left right] :as zip})
(move-right zip num)

move right from current position

(-> (zip/from-cursor '[1 2 [| 3 4]]) (move-right) (zip/cursor)) => '([1 2 [3 | 4]])

move right from current position

(-> (zip/from-cursor '[1 2 [| 3 4]])
    (move-right)
    (zip/cursor))
=> '([1 2 [3 | 4]])
raw docstring

move-right-mostclj

(move-right-most zip)

move to right-most point of current branch

(-> (zip/from-cursor '[1 2 [| 3 4]]) (move-right-most) (zip/cursor)) => '([1 2 [3 4 |]])

move to right-most point of current branch

(-> (zip/from-cursor '[1 2 [| 3 4]])
    (move-right-most)
    (zip/cursor))
=> '([1 2 [3 4 |]])
raw docstring

move-right?clj

(move-right? zip)

check if can move right from current position

(-> (zip/from-cursor '[1 2 [3 | 4]]) (move-right?)) => true

(-> (zip/from-cursor '[1 2 [3 4 |]]) (move-right?)) => false

check if can move right from current position

(-> (zip/from-cursor '[1 2 [3 | 4]])
    (move-right?))
=> true

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (move-right?))
=> false
raw docstring

move-top-mostclj

(move-top-most zip)

move to top-most point of the tree

(-> (zip/from-cursor '[1 2 [| 3 4]]) (move-top-most) (zip/cursor)) => '(| [1 2 [3 4]])

move to top-most point of the tree

(-> (zip/from-cursor '[1 2 [| 3 4]])
    (move-top-most)
    (zip/cursor))
=> '(| [1 2 [3 4]])
raw docstring

move-upclj

(move-up zip)
(move-up zip num)

move up from current position

(-> (zip/from-cursor '[1 2 [| 3 4]]) (move-up) (zip/cursor)) => '([1 2 | [3 4]])

move up from current position

(-> (zip/from-cursor '[1 2 [| 3 4]])
    (move-up)
    (zip/cursor))
=> '([1 2 | [3 4]])
raw docstring

move-up?clj

(move-up? zip)

check if can move up from current position

(-> (zip/from-cursor '[1 2 [3 4 |]]) (move-up?)) => true

check if can move up from current position

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (move-up?))
=> true
raw docstring

nextclj

(next zip)

move cursor through the tree in depth first order

(->> (from-cursor '[| 1 [2 [6 7] 3] [4 5]]) (iterate next) (take-while identity) (map node)) => '(1 [2 [6 7] 3] 2 [6 7] 6 7 3 [4 5] 4 5)

move cursor through the tree in depth first order

(->> (from-cursor '[| 1 [2 [6 7] 3] [4 5]])
     (iterate next)
     (take-while identity)
     (map node))
=> '(1 [2 [6 7] 3] 2 [6 7] 6 7 3 [4 5] 4 5)
raw docstring

nodeclj

(node zip)

accesses the node directly right of the cursor

(-> (from-cursor [1 '| 2 3]) (node)) => 2

accesses the node directly right of the cursor

(-> (from-cursor [1 '| 2 3])
    (node))
=> 2
raw docstring

op-lookupclj


postwalkclj

(postwalk zip f)

emulates clojure.walk/postwalk behavior with zipper

(-> (vector-zip [1 [2 [6 7] 3] [4 5]]) (find-next even?) (up) (postwalk (fn [v] (if (vector? v) (conj v 100) (+ v 100)))) (root-node)) => [1 [102 [106 107 200] 103 100] [4 5]]

emulates clojure.walk/postwalk behavior with zipper

(-> (vector-zip [1 [2 [6 7] 3] [4 5]])
    (find-next even?)
    (up)
    (postwalk (fn [v] (if (vector? v)
                        (conj v 100)
                        (+ v 100))))
   (root-node))
=> [1 [102 [106 107 200] 103 100] [4 5]]
raw docstring

prevclj

(prev zip)

move cursor in reverse through the tree in depth first order

(->> (from-cursor '[1 [2 [6 7] 3] [4 | 5]]) (iterate prev) (take 10) (map node)) => '(5 4 [4 5] 3 7 6 [6 7] 2 [2 [6 7] 3] 1)

move cursor in reverse through the tree in depth first order

(->> (from-cursor '[1 [2 [6 7] 3] [4 | 5]])
     (iterate prev)
     (take 10)
     (map node))
=> '(5 4 [4 5] 3 7 6 [6 7] 2 [2 [6 7] 3] 1)
raw docstring

prewalkclj

(prewalk zip f)

emulates clojure.walk/prewalk behavior with zipper

(-> (vector-zip [1 [2 [6 7] 3] [4 5]]) (prewalk (fn [v] (if (vector? v) (conj v 100) (+ v 100)))) (root-node)) => [101 [102 [106 107 200] 103 200] [104 105 200] 200]

emulates clojure.walk/prewalk behavior with zipper

(-> (vector-zip [1 [2 [6 7] 3] [4 5]])
    (prewalk (fn [v] (if (vector? v)
                       (conj v 100)
                       (+ v 100))))
    (root-node))
=> [101 [102 [106 107 200] 103 200] [104 105 200] 200]
raw docstring

replace-leftclj

(replace-left {:keys [left] :as zip} element)

replace element left of the current position

(-> (zip/from-cursor '[1 2 | 3]) (replace-left "10") (zip/cursor)) => '([1 "10" | 3])

replace element left of the current position

(-> (zip/from-cursor '[1 2 | 3])
    (replace-left "10")
    (zip/cursor))
=> '([1 "10" | 3])
raw docstring

replace-rightclj

(replace-right {:keys [right] :as zip} element)

replace element right of the current position

(-> (zip/from-cursor '[1 2 | 3]) (replace-right "10") (zip/cursor)) => '([1 2 | "10"])

replace element right of the current position

(-> (zip/from-cursor '[1 2 | 3])
    (replace-right "10")
    (zip/cursor))
=> '([1 2 | "10"])
raw docstring

(right zip)

move cursor right (-> (from-cursor [1 '| 2 3]) (right) (cursor)) => '([1 2 | 3])

move cursor right
(-> (from-cursor [1 '| 2 3])
    (right)
    (cursor))
=> '([1 2 | 3])
raw docstring

right-most?clj

(right-most? zip)

check if at right-most point of a branch

(-> (zip/from-cursor '[1 2 [3 4 |]]) (right-most?)) => true

check if at right-most point of a branch

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (right-most?))
=> true
raw docstring

right-nodeclj

(right-node zip)

element directly right of current position

(-> (zip/from-cursor '[1 2 3 | 4]) (right-node)) => 4

element directly right of current position

(-> (zip/from-cursor '[1 2 3 | 4])
    (right-node))
=> 4
raw docstring

right-nodesclj

(right-nodes zip)

all elements right of current position

(-> (zip/from-cursor '[1 2 | 3 4]) (right-nodes)) => '(3 4)

all elements right of current position

(-> (zip/from-cursor '[1 2 | 3 4])
    (right-nodes))
=> '(3 4)
raw docstring

root-nodeclj

(root-node zip)

accesses the top level node

(-> (vector-zip [[[3] 2] 1]) (move-bottom-most) (root-node)) => [[[3] 2] 1]

accesses the top level node

(-> (vector-zip [[[3] 2] 1])
    (move-bottom-most)
    (root-node))
=> [[[3] 2] 1]
raw docstring

seq-zipclj

(seq-zip root)

constructs a sequence zipper

(seq-zip '(1 2 3 4 5)) => (contains {:left (), :right '((1 2 3 4 5)), :parent :top})

constructs a sequence zipper

(seq-zip '(1 2 3 4 5))
=> (contains {:left (),
              :right '((1 2 3 4 5)),
              :parent :top})
raw docstring

siblingsclj

(siblings {:keys [left right] :as zip})

all elements left and right of current position

(-> (zip/from-cursor '[1 2 | 3 4]) (siblings)) => '(1 2 3 4)

(-> (zip/from-cursor '[1 [2 | 3] 4]) (siblings)) => '(2 3)

all elements left and right of current position

(-> (zip/from-cursor '[1 2 | 3 4])
    (siblings))
=> '(1 2 3 4)

(-> (zip/from-cursor '[1 [2 | 3] 4])
    (siblings))
=> '(2 3)
raw docstring

surroundclj

(surround zip)
(surround zip num)

adds additional levels to the element

(-> (vector-zip 1) (surround 2) (root-node)) => [[1]]

adds additional levels to the element

(-> (vector-zip 1)
    (surround 2)
    (root-node))
=> [[1]]
raw docstring

top-most?clj

(top-most? zip)

check if at top-most point of the tree

(-> (zip/from-cursor [1 2 [3 4 '|]]) (top-most?)) => false

(-> (zip/from-cursor '[1 2 [3 4 |]]) (move-up) (move-up) (top-most?)) => true

check if at top-most point of the tree

(-> (zip/from-cursor [1 2 [3 4 '|]])
    (top-most?))
=> false

(-> (zip/from-cursor '[1 2 [3 4 |]])
    (move-up)
    (move-up)
    (top-most?))
=> true
raw docstring

traverseclj

(traverse zip command)
(traverse zip command & more)

traverse through zipper with data

(-> (traverse (vector-zip [1 [[2] 3]]) :down :right [:down 2] [:right] [:insert-right 1 2 3 4]) (cursor)) => '([1 [[2 | 4 3 2 1] 3]])

traverse through zipper with data

(-> (traverse (vector-zip [1 [[2] 3]])
              :down
              :right
              [:down 2]
              [:right]
              [:insert-right 1 2 3 4])
   (cursor))
=> '([1 [[2 | 4 3 2 1] 3]])
raw docstring

upclj

(up zip)

move cursor up

(-> (from-cursor [1 '| 2 3]) (up) (cursor)) => '(| [1 2 3])

(-> (from-cursor [1 [['| 2] 3]]) (up) (cursor)) => '([1 [| [2] 3]])

move cursor up

(-> (from-cursor [1 '| 2 3])
    (up)
    (cursor))
=> '(| [1 2 3])

(-> (from-cursor [1 [['| 2] 3]])
    (up)
    (cursor))
=> '([1 [| [2] 3]])
raw docstring

vector-zipclj

(vector-zip root)

constructs a vector based zipper

(vector-zip [1 2 3 4 5]) => (contains {:left (), :right '([1 2 3 4 5]) :parent :top})

constructs a vector based zipper

(vector-zip [1 2 3 4 5])
=> (contains {:left (),
              :right '([1 2 3 4 5])
              :parent :top})
raw docstring

zipperclj

(zipper root {:keys [branch? children make-node] :as meta})

constructs a zipper

(zipper '(1 2 3) {:branch? seq? :children identity :make-node identity}) => zipper?

constructs a zipper

(zipper '(1 2 3) {:branch?   seq?
                  :children  identity
                  :make-node identity})
=> zipper?
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close