The Many Faces of D - slides

Peter Alexander peter.alexander.au at gmail.com
Sun Oct 3 10:32:54 PDT 2010


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> On 10/03/2010 10:21 AM, Simen kjaeraas wrote:
> > unittest {
> > assert( equal( ( list!"2 * a" | [1,2,3,4,5] & where!"a & 1" ), [2,6,10]
> > ) );
> > assert( equal( ( list!"2 * a" | [1,2,3] ), [2,4,6] ) );
> > }
> I wonder to what extent this improves
> assert(equal(map!"2 * a"(filter!"a & 1"([1,2,3,4,5])), [2,6,10]));
> One thing that's nicer with comprehensions is that you save a bit on
> nested parens.
> Andrei

It would be nice if we could just write:

assert(equal(iota(1,6).filter!("a&1").map!("2*a"), [2,6,10]));

Incidentally, why doesn't the uniform function call syntax allow this?



More information about the Digitalmars-d mailing list