2

I it possible to create a two dimensional array of two dimensional arrays in Delphi; and if so how do you access the addresses in it?

My aim is to create something similar to a sudoku grid where you have smaller grids inside of a bigger one.

It would work much better in stead of ex. Declaring multiple 2D arrays of the same type or one big array.

2
  • On a side note, I don't know what you'd be using this for, but lets say you want to make a map with zooming. The more you zoom in, the finer the detail becomes, thus the smaller the grid lines are. Kinda like Google Maps/Earth. In this case, there isn't a grid within a grid, but rather a single scalable grid using, for example, a double type for Longitude/Latitude. Not sure if this may help depending on your intention. Commented Mar 18, 2016 at 13:28
  • @Jerry We know what it is used for, Sudoku Commented Mar 20, 2016 at 22:56

1 Answer 1

5

Something like

type
  TSmallGrid = array[1..3, 1..3] of Integer;
  TBigGrid = array[1..3, 1..3] of TSmallGrid;

should work. Access to BigArray: TBigGrid would be with standard Pascal array syntax:

  MyInt := BigArray[1, 2, 1, 2]; // or even BigArray[1, 2][1, 2] to emphasize the nesting

or

  SmallArray := BigArray[1, 2];
Sign up to request clarification or add additional context in comments.

2 Comments

Actually, if you want to emphasize that these are nested twodimensional arrays, you can also do MyInt := BigArray[1, 2][1, 2];.;
Thanks, @Rudy, integrated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.