This commit is contained in:
Matthew Davidson 2023-01-04 16:47:10 +01:00
parent 2f1fa3cc3b
commit ce7411159d

View file

@ -10,21 +10,21 @@
(meditations
"A sequence operation with only one argument often returns a transducer"
(= __
(= '(2 3 4)
(sequence example-transducer [1 2 3]))
"Consider that sequence operations can be composed as transducers"
(= __
(= [2 4]
(transduce transforms conj [1 2 3]))
"We can do this eagerly"
(= __
(= [2 4]
(into [] transforms [1 2 3]))
"Or lazily"
(= __
(= '(2 4)
(sequence transforms [1 2 3]))
"The transduce function can combine mapping and reduction"
(= __
(= 6
(transduce transforms + [1 2 3])))