arraystypes

What should be the type expression of a 2D array?


Type expression of an array with M elements of type T is

array(1...M,T)

Then what it should be for an 2D array with M rows and N columns? Should it be a cartesian product of two arrays? Please help.


Solution

  • For M*N array, type expression will be

    array(1...M,array(1...N, type))

    where M is the no of rows and N is the no of columns. Just consider a 2D array as an array of arrays.