The essential folds: map
, mapcat
, take
, filter
, some
, any?
,
into
, etc, plus common fold combinators.
"Now we will tesser, we will wrinkle again. Do you understand?" "No," Meg said flatly. Mrs. Whatsit sighed. "Explanations are not easy when they are about things for which your civilization still has no words. Calvin talked about traveling at the speed of light. You understand that, little Meg?" "Yes," Meg nodded. "That, of course, is the impractical, long way around. We have learned to take short cuts wherever possible." "Sort of like in math?" Meg asked. "Like in math."
-- Madeline L'Engle, A Wrinkle In Time.
Tesser structures partly-concurrent folds.
(tesser some-collections a-fold)
uses a-fold
to combine some information
from every element in some-collections
: a collection of collections of
inputs. Like reducers and transducers, it takes fold as the ultimate
collection operation. Unlike transducers, Tesser folds are not sequential.
They include an explicitly concurrent reduction over arbitrary partitions of
the collection, and a sequential reduction over those reduced values,
termed combine. Like transducers, Tesser folds can also map and filter
their inputs, and perform post-processing transformation after each reduction
and the combine step.
Tesser folds can be composed with the standard collection threading idioms,
and evaluated against a collection of collections using (tesser colls fold)
.
(->> (t/map inc)
(t/filter even?)
(t/fold +)
(t/tesser [[1 2 3] [4 5 6]]))
; => 2 + 4 + 6 = 12
The essential folds: `map`, `mapcat`, `take`, `filter`, `some`, `any?`, `into`, etc, plus common fold combinators. > "Now we will tesser, we will wrinkle again. Do you understand?" "No," > Meg said flatly. Mrs. Whatsit sighed. "Explanations are not easy when they > are about things for which your civilization still has no words. Calvin > talked about traveling at the speed of light. You understand that, little > Meg?" "Yes," Meg nodded. "That, of course, is the impractical, long way > around. We have learned to take short cuts wherever possible." "Sort of > like in math?" Meg asked. "Like in math." > > -- Madeline L'Engle, *A Wrinkle In Time*. Tesser structures partly-concurrent folds. `(tesser some-collections a-fold)` uses `a-fold` to combine some information from every element in `some-collections`: a collection of collections of inputs. Like reducers and transducers, it takes *fold* as the ultimate collection operation. Unlike transducers, Tesser folds are not sequential. They include an explicitly concurrent reduction over arbitrary partitions of the collection, and a sequential reduction over *those* reduced values, termed *combine*. Like transducers, Tesser folds can also map and filter their inputs, and perform post-processing transformation after each reduction and the combine step. Tesser folds can be composed with the standard collection threading idioms, and evaluated against a collection of collections using `(tesser colls fold)`. (->> (t/map inc) (t/filter even?) (t/fold +) (t/tesser [[1 2 3] [4 5 6]])) ; => 2 + 4 + 6 = 12
Drop-in replacement for reducers/fold
and core/reduce
, where order
doesn't matter.
Drop-in replacement for `reducers/fold` and `core/reduce`, where order doesn't matter.
Toolbox.
Toolbox.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close