Re: Fixed matrix rows joining

2012-01-15 Thread Peter Alexander
On 15/01/12 2:19 AM, Andrej Mitrovic wrote: I guess join() could be specialized for static arrays and then just do a dup and a cast? Would that work ok? There should be no need to allocate extra memory to do this.

Re: Fixed matrix rows joining

2012-01-15 Thread Timon Gehr
On 01/15/2012 02:38 AM, bearophile wrote: If I have a simple fixed-size matrix and I need to linearize (flatten) it, the function join() seems to not not work: import std.array: join; void main() { int[4][4] table; join(table); } test.d(4): Error: template std.array.join(RoR,R) if

Re: Fixed matrix rows joining

2012-01-14 Thread Andrej Mitrovic
A rectangular array is really just one array, is it not? From a syntax point it looks like a multidimensional array but really it's just a single linear piece of memory, so just cast it: void main() { int[2][4] table; table[0][] = 0; table[1][] = 1; table[2][] = 2; table[3][]

Re: Fixed matrix rows joining

2012-01-14 Thread Andrej Mitrovic
I guess join() could be specialized for static arrays and then just do a dup and a cast? Would that work ok?