(combine-with f & ds)
Alias for (fmap #(apply f %) (drains ds)).
Alias for (fmap #(apply f %) (drains ds)).
(drain rf)
(drain rf init)
(drain xf rf init)
Returns a new drain that consists of a reducing fn rf and initial value init.
rf must be a valid reducing fn, ie. it must have arity-1 signature as well as arity-2. If your rf only has arity-1 signature, try using clojure.core/completing. This function can be passed a transducer xf optionally, in which case the drain's reducing fn will be (xf rf).
Returns a new drain that consists of a reducing fn rf and initial value init. rf must be a valid reducing fn, ie. it must have arity-1 signature as well as arity-2. If your rf only has arity-1 signature, try using clojure.core/completing. This function can be passed a transducer xf optionally, in which case the drain's reducing fn will be (xf rf).
(drain? x)
Returns true if x is a drain.
Returns true if x is a drain.
(drains ds)
Returns a drain that manages multiple underlying drains.
ds can be either a vector or a map. The resulting value of aggregation will be
the same form as ds. Thus, for example, the result of the following expression
will be [0 9]
:
(require '[drains.core :as d]) (d/reduce (d/drains [(d/drain min ##Inf) (d/drain max ##-Inf)]) (range 10))
whereas the following will result in {:min 0, :max 9}
:
(d/reduce (d/drains {:min (d/drain min ##Inf) :max (d/drain max ##-Inf)}) (range 10))
Returns a drain that manages multiple underlying drains. ds can be either a vector or a map. The resulting value of aggregation will be the same form as ds. Thus, for example, the result of the following expression will be `[0 9]`: (require '[drains.core :as d]) (d/reduce (d/drains [(d/drain min ##Inf) (d/drain max ##-Inf)]) (range 10)) whereas the following will result in `{:min 0, :max 9}`: (d/reduce (d/drains {:min (d/drain min ##Inf) :max (d/drain max ##-Inf)}) (range 10))
(fmap f d)
Returns a drain that applies f to the result of the underlying drain.
Eg. (require '[drains.core :as d]) (d/reduce (d/fmap (fn [sum] {:sum sum}) (d/drain + 0)) (range 10)) ;=> {:sum 45}
Returns a drain that applies f to the result of the underlying drain. Eg. (require '[drains.core :as d]) (d/reduce (d/fmap (fn [sum] {:sum sum}) (d/drain + 0)) (range 10)) ;=> {:sum 45}
(fold combinef d xs)
(fold n combinef d xs)
Aggregation fn analogous to clojure.core.reducers/fold accepting a drain instead of a reducing fn.
Aggregation fn analogous to clojure.core.reducers/fold accepting a drain instead of a reducing fn.
(group-by key-fn d)
Returns a drain that manages an isolated copy of the underlying drain for each key (regarding key-fn).
The result of the drain will be a map of key to the result of the corresponding underlying drain.
Eg. (require '[drains.core :as d]) (d/reduce (d/group-by odd? (d/drain conj [])) (range 5)) ;=> {false [0 2 4], true [1 3]}
(d/reduce (d/group-by #(mod % 2) (d/drain + 0)) (range 5)) ;=> {0 6, 1 4}
Returns a drain that manages an isolated copy of the underlying drain for each key (regarding key-fn). The result of the drain will be a map of key to the result of the corresponding underlying drain. Eg. (require '[drains.core :as d]) (d/reduce (d/group-by odd? (d/drain conj [])) (range 5)) ;=> {false [0 2 4], true [1 3]} (d/reduce (d/group-by #(mod % 2) (d/drain + 0)) (range 5)) ;=> {0 6, 1 4}
(reduce drain xs)
Aggregation fn analogous to clojure.core/reduce accepting a drain instead of a reducing fn.
Aggregation fn analogous to clojure.core/reduce accepting a drain instead of a reducing fn.
(reductions drain xs)
Aggregation fn analogous to clojure.core/reductions accepting a drain instead of a reducing fn.
Aggregation fn analogous to clojure.core/reductions accepting a drain instead of a reducing fn.
(with xf d)
Returns a drain with a transducer attached.
Eg. (require '[drains.core :as d]) (d/reduce (d/with (filter even?) (d/drain + 0)) (range 10)) ;=> 20
Returns a drain with a transducer attached. Eg. (require '[drains.core :as d]) (d/reduce (d/with (filter even?) (d/drain + 0)) (range 10)) ;=> 20
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close