www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - operations on rectangular arrays

reply "dominic jones" <dominic.jones gmx.co.uk> writes:
Hello,

This code snippet:
   int[][] A = [[1, 2], [2, 3]];
   int[][] B = [[2, 3], [1, 2]];
   int[2][2] C;
   C = A[][] + B[][];

fails with the message:
   "Error: cannot implicitly convert expression (A[][] + B[][]) of 
type int[][] to int[2LU][]"

Is there a succinct work-around (i.e. without using foreach)? And 
will such statements one day be possible?

The section in http://dlang.org/arrays.html on rectangular arrays 
offers no use cases to follow.

Thank you,
Dominic Jones
Nov 14 2012
parent "bearophile" <bearophileHUGS lycos.com> writes:
dominic jones:

 Is there a succinct work-around (i.e. without using foreach)?
2D built-in array operations are not supported. APL-style orthogonality isn't at home in D, it seems. Bye, bearophile
Nov 14 2012