Utilities helping to make transducer functions out of regular functions. Transducers can be pipelined like thread-first or thread-list, but using regular function composition.
Unlike thread-first or thread-list, a pipeline of transducers processes a single elemnt through all functions at a time, eliminating the need to create multiple intermediate collections.
Also includes xreduce, a version of reduce that returns a transducer function (this function is seemingly missing from the standard library).
Utilities helping to make transducer functions out of regular functions. Transducers can be pipelined like thread-first or thread-list, but using regular function composition. Unlike thread-first or thread-list, a pipeline of transducers processes a single elemnt through all functions at a time, eliminating the need to create multiple intermediate collections. Also includes xreduce, a version of reduce that returns a transducer function (this function is seemingly missing from the standard library).
(<-f f)
Translate an arbitrary function f into a transducing function that can be composed into a transducer chain using (comp f1 f2 f3 ... fn).
For creating a reduce transducer with an initial value, pass a vector with the reducing function in the initial element and the initial value in the second element.
Translate an arbitrary function f into a transducing function that can be composed into a transducer chain using (comp f1 f2 f3 ... fn). For creating a reduce transducer with an initial value, pass a vector with the reducing function in the initial element and the initial value in the second element.
(<-fns & fns)
Compute a transducer function composing fns according to Unix pipe semantics as defined in <-f.
Compute a transducer function composing fns according to Unix pipe semantics as defined in <-f.
(xmapcat f)
Return a transducer calling (mapcat f) for an arbitrary f. Results are interpreted as follows:
Return a transducer calling (mapcat f) for an arbitrary f. Results are interpreted as follows: * If (f x) is a map, seq, or set, it is returned as-is. * If (f x) is nil, patterns/nothing is returned. * Otherwise, the result is wrapped in a vector and returned.
(xreduce f)
(xreduce f initial-value)
A version of reduce that returns a transducer function. There are two arities of this function, one accepting a single reducer function and one that accepts a reducer function and an initial value. Just like the transducer-producing arities in the standard library (e.g.: map, mapcat), this function does not include an arity accepting an input collection.
Semantics of the transducer function reduce are the same as the semantics of a regular reduce.
A version of reduce that returns a transducer function. There are two arities of this function, one accepting a single reducer function and one that accepts a reducer function and an initial value. Just like the transducer-producing arities in the standard library (e.g.: map, mapcat), this function does not include an arity accepting an input collection. Semantics of the transducer function reduce are the same as the semantics of a regular reduce.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close