https://issues.dlang.org/show_bug.cgi?id=13016
Issue ID: 13016
Summary: std.algorithm.scanl
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: [email protected]
Reporter: [email protected]
Add a function scanl (like haskell's scanl) to std.algorithm, that acts like
reduce but returns the intermediate results in a range.
void main() {
import std.stdio, std.algorithm;
writeln(scanl!((x,y)=>x+y)([1,2,3,4,5])); // prints [3,6,10,15]
uint[] durations = [10,10,15,20,10];
uint[] timeSteps = scanl!( (x,y) => x+y ) (0,durations);
writeln(timeSteps); // prints [10,20,35,55,65]
}
Maybe suggest another name.
--