www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Split by length?

reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Is there something in Phobos with which I could do:

auto arr = [1, 2, 3, 4, 5, 6];

int[][] newarr = arr.splitLength(2);
assert(newarr.length == 3);

?
Aug 14 2011
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Mon, 15 Aug 2011 05:49:59 +0300, Andrej Mitrovic  
<andrej.mitrovich gmail.com> wrote:

 Is there something in Phobos with which I could do:

 auto arr = [1, 2, 3, 4, 5, 6];

 int[][] newarr = arr.splitLength(2);
 assert(newarr.length == 3);

Almost but not quite: auto newarr = cast(int[2][])arr; -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Aug 24 2011