Add test examples.
This commit is contained in:
parent
61b59472d8
commit
95db7b5873
1 changed files with 18 additions and 0 deletions
|
|
@ -292,6 +292,24 @@ Many common transducer use cases can be expressed more elegantly with traverse-a
|
||||||
;; => 9
|
;; => 9
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Here are some more examples of using traverse-all:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
=> (into [] (traverse-all :a) [{:a 1} {:a 2}])
|
||||||
|
[1 2]
|
||||||
|
=> (transduce (traverse-all [ALL :a])
|
||||||
|
+
|
||||||
|
0
|
||||||
|
[[{:a 1} {:a 2}] [{:a 3}]])
|
||||||
|
6
|
||||||
|
=> (transduce (comp (mapcat identity)
|
||||||
|
(traverse-all :a))
|
||||||
|
(completing (fn [r i] (if (= i 4) (reduced r) (+ r i))))
|
||||||
|
0
|
||||||
|
[[{:a 1}] [{:a 2}] [{:a 4}] [{:a 5}]])
|
||||||
|
3
|
||||||
|
```
|
||||||
|
|
||||||
# Path Macros
|
# Path Macros
|
||||||
|
|
||||||
## declarepath
|
## declarepath
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue