findSplit
Gecko via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 25 11:56:43 PDT 2014
Hello,
is there a pretty way to split a range into 3 pieces, like
findSplit, just with a predicate instead of comparing it with an
element.
Like this :
void main() {
import std.algorithm, std.stdio;
auto list = [1,2,3,4,5,6,7];
writeln(findSplit!(x => x == 3 )(list));
//should print Tuple!(....) ([1,2], [3], [4,5,6,7])
}
findSplit accepts a predicate but it doesnt compile for me if i
use an other function than ((a,b) => a == b).
More information about the Digitalmars-d-learn
mailing list