D2's std.algorithm
Bill Baxter
dnewsgroup at billbaxter.com
Mon Dec 10 20:42:27 PST 2007
> sort!("a > b")(array);
I just wanted to say that this is BRILLIANT! Zero call overhead, zero
syntax overhead, compile-time lambda functions!
All the algorithms should support this syntax so we can do sexy
compile-time lambda one-liners like:
find!("a.some_member > 10")(array);
or
partition!("a.call_something() !is null")(array);
etc.
And probably those should allow a data arg passed as 'b' to the lambda
function so you could do something like
find!("a.some_member > b")(array, 10);
Or even use template varargs and number the args automatically to allow:
find!("a.x > b && a.w < c")(array, 10, 20);
It would just sequentially name the arguments b,c,d,e... etc.
Or even make it like C#/Tango's format string patterns since the string
can be processed before mixing it in.
find!("a.x > {1} && a.w < {2}")(array, 10, 20);
That would be excellent. Take that boost::lambda!
--bb
More information about the Digitalmars-d
mailing list