Section 2.3 is about Scan operations, that are like reduce or fold, but keep all the intermediate results too:+\ of 3 1 2 4 is 3 4 6 10Some lazy scans are present in the Haskell Prelude too (and in Mathematica) (the Prelude contains functions and constants that are loaded on default):http://zvon.org/other/haskell/Outputprelude/scanl_f.htmlI think scans are not present in Phobos. Maybe one or two are worth adding.
See attached. Mayhaps I should post this as a pull request?
------------------ Section 2.5 suggests to generalize the dot product:If the + and * of the Fortran 77 DO loops for inner product are replaced by other functions, a whole family of interesting inner products appear,<Some examples of usage (in J language): Associative search *./..=y Inverted associative x+./..~:y Minima of residues for primes x<./..|y Transitive closure step on Booleans y+./..*.y Minima of maxima x<./..>.yMaybe a higher order function named "dot" (that takes two callables) is worth adding to Phobos. But I am not sure.
So that's basically mapReduce, right? We've got that, just not as succinct. -- Simen
scan.d
Description: Binary data
