std.array.array seems to return flatten copy of input

Tobias Pankrath tobias at pankrath.net
Fri Apr 4 13:26:02 PDT 2014


On Friday, 4 April 2014 at 20:19:53 UTC, Olivier Grant wrote:
> Hi,
>
> I've started using D as a scripting language at work and for 
> personal projects as a means to learn the language and I've 
> bumped into a case where I would like to iterate a slice by a 
> certain number of elements at a time such that :
>
> foreach(s; [1,2,3,4].splice!(2))
> {
>    writeln(s);
> }
>
> would print :
>
> [1,2]
> [3,4]
>
> First of all, is there such a function in D's standard library 
> as I didn't seem to be able to find one ?

http://dlang.org/phobos/std_range.html#chunks


More information about the Digitalmars-d-learn mailing list