DEV Community

Discussion on: #001 DS&A - Operators and Arrays

 
pentacular profile image
pentacular

There are such things are truly multi-dimensional arrays, just not in C.

For example, in pascal

type
  StatusType = (X, O, Blank);
  BoardType = array[1..3,1..3] of StatusType;
var
  Board : BoardType;

for count1 := 1 to 3 do
  for count2 := 1 to 3 do
    Board[count1, count2] := Blank;

Or in Common Lisp

(let ((a (make-array '(4 3))))
  (aref a i j))

This is not a criticism of C -- deciding to use arrays of arrays rather multi-dimensional arrays is a perfectly reasonable design choice.

It's just a design choice that should be understood clearly. :)