On 12/15/10, Stephan Soller <stephan.sol...@helionweb.de> wrote: > > So, _if_ we can figure out a way to do some nice chaining of such calls > we can get: > > [1, 2, 3, 4, 5].filter!((e){ return e > 3; }) > .map!((e){ return e*e; }); > > Or if you don't like delegates and don't mind obvious compile time black > magic: > > [1, 2, 3, 4, 5].filter!("a > 3").map!("a * a"); >
You might use pipe! as an alternative: import std.algorithm; import std.functional; import std.stdio; void main() { int[] arr = [1, 2, 3, 4, 5]; auto result = pipe!( filter!("a>3"), map!("a * a") )(arr); writeln(result); } But I can't seem to do the same with delegates: import std.algorithm; import std.functional; import std.stdio; void main() { int[] arr = [1, 2, 3, 4, 5]; pipe!( filter!( (e){ return e > 3; } ), map!( (e){ return e*e; } ) )(arr); } chain.d(9): Error: expression template filter(Range) is not a valid template value argument chain.d(9): Error: expression template map(Range) is not a valid template value argument