July 25, 2014 findSplit | ||||
|---|---|---|---|---|
| ||||
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).
| ||||
July 25, 2014 Re: findSplit | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Gecko | On Friday, 25 July 2014 at 18:56:44 UTC, Gecko wrote:
> findSplit accepts a predicate but it doesnt compile for me if i use an other function than ((a,b) => a == b).
Not at the moment. I've been working on a patch that makes the `findSplit*` family of algorithms as powerful as `find`, including support for your use case.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply