range slicing

bearophile bearophileHUGS at lycos.com
Tue Feb 11 13:53:06 PST 2014


kuba:

> auto dir = "/data/home/kuba";
> auto dirs = dirEntries(dir,SpanMode.shallow);
> auto arr =  array(dirs);
> writeln(arr[2..4]);

In Python standard library there is an islice(), that performs a 
lazy slicing. I think there's not a similar function in Phobos, 
but you can use ranges to skip the leading part. So you can use 
drop(2).take(2) to take the slice. All lazily.

I also suggest to ask such questions in D.learn.

Bye,
bearophile


More information about the Digitalmars-d mailing list