ClojureDocs

Nav

Namespaces

down

clojure.zip

Available since 1.0
  • (down loc)
Returns the loc of the leftmost child of the node at this loc, or
nil if no children
1 Example
(use 'clojure.zip)
;; def a tree struct
;;    .
;;   / \
;;  .   0
;; / \
;; 1 2
(def tree
  (vector-zip
    [[1 2] 0]))

;;   #0          #1          #2
;;    x           .           .
;;   / \         / \         / \
;;  .   0       x   0       .   0
;; / \         / \         / \
;; 1 2         1 2         x 2

;; #0
(-> tree
    node) ;; => [[1 2] 0]
;; #1
(-> tree
    down
    node) ;; => [1 2]
;; #2
(-> tree
    down
    down
    node) ;; => 1

;; notice the leftmost child / first element
See Also

Creates a new zipper structure. branch? is a fn that, given a node, returns true if can have c...

Added by phreed
0 Notes
No notes for down