While we were discussing lambda syntax..

Andrej Mitrovic none at none.none
Fri Dec 31 08:08:54 PST 2010


There was some heated discussion about the disadvantages of using strings as a predicate, and coming up with some new syntax that DMD would support. Some people did not like using strings and would rather use _ or _0/_1 instead of this:

auto arr = [0,1,2,3,4];
auto plusOne = map!("a + b")(arr);

Well, while we were arguing about a new syntax, a clever fellow named Phillipe Sigaud has already come up with a way to use predicates without resorting to strings:

auto arr = [0,1,2,3,4];
auto plusOne = map!(_0 + _1)(arr);

Check it out: http://svn.dsource.org/projects/dranges/trunk/dranges/docs/lambda.html

Make sure you read the features section. Is that awesome or what?


More information about the Digitalmars-d mailing list