Another rambling musing by a Dynamic Programmer - map!

John Carter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 23 19:34:29 PDT 2014


So in Ruby and R and Scheme and... I have happily used map / 
collect for years and years.

Lovely thing.

So I did the dumb obvious of

    string[] stringList = map!...;

And D barfed, wrong type, some evil voldemort thing again.

So..

    auto stringList = map!....;

and we're good..

and happily use it as
    foreach( s; stringList)....

Suddenly the words in the map! documentation made sense to me... 
unlike Ruby, map doesn't allocate and populate an array. It just 
returns a lazy range.

No array is allocated (unless I ask for one), it just does the 
lambda when I want it in the foreach!

Cool! Very very cunning. Very light on resources.

I itch to get D working in the OpenEmbedded environment...


More information about the Digitalmars-d-learn mailing list