1.3.0 permalink Arrow_down_16x16

prewalk

clojure.walk

  • (prewalk f form)
Like postwalk, but does pre-order traversal.

1 Example top

  • ;; From http://stackoverflow.com/questions/8089074/idiomatically-iterating-over-a-2-or-higher-dimensional-sequence-in-clojure/8091544#8091544
    
    (def matrix [[1 2 3]
                 [4 5 6]
                 [7 8 9]])
    (use 'clojure.walk :only [prewalk])
    
    (prewalk #(if (number? %) (inc %) %) matrix)
    => [[2 3 4] [5 6 7] [8 9 10]]
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/walk.clj:58 top

(defn prewalk
  "Like postwalk, but does pre-order traversal."
  {:added "1.1"}
  [f form]
  (walk (partial prewalk f) identity (f form)))
Vars in clojure.walk/prewalk:
Used in 0 other vars

Comments top

No comments for prewalk. Log in to add a comment.