Is there a way to pass Arrays as Parms for a Method? For example:
A1 : Array[0…2, 0…3] of Integer = . . .
A2 : Array[0…4, 0…8] of Integer = . . .
DoIt(4, 8, A2); // Calling a Method DoIt:
Method DoIt(maxRow, maxCol : Integer, AnArray : Array)
Begin
For var iX = 0 to MaxRow Do Begin
For var iY = 0 to MaxCol Do Begin
DoSomething with AnArray[iX, iY]
End; //EndFOR iY
End; //EndFOR iX
End;//EndMETH DoIt
Maybe do it with Array Pointers if not Array Parms?
Yes. That will take a Dynamic Array Pfänder, which a static array is assignment compatible to. Inside the method, you can use length() to determine the actual size of the array (it will always be zero-based).
Presumably, then, I can use a 3D Array of Integer by:
Method DoIt(maxX, maxY, maxZ : Integer, AnArray : Array of Integer) where AnArray can be considered as AnArray[0…maxX, 0…maxY, 0…maxZ)], right?
for a 4D by adding the length-1 of the 4th dimension?
Thanks, wuping. For my curiosity only: the name, wuping, looks Chinese to me. Are you Chinese? What country are you in? You need not answer. My 13yo daughter has been learning Chinese from an 8th grade girl in her class. She & family are 1st generation from China. Chinese people have an outstanding reputation in the US & I guess elsewhere.
What I had meant is - to put the 2D array data into a 1D array, while passing the 1D array together with dimensions len1 and len2, as an alternative to directly passing the param as array of array of integer. TensorFlow does this a lot - the internal data is just one big chunk of memory (as 1D array), but an additional Shape information is provided for the dimension information.
OK, guys, thanks. To simplify my life I’m only going to create 1D Arrays & Map them to 2D, 3D, 4D, … as I may need them. Modern computers are so fast the time lost is insignificant vs what a compiler could create directly. Saves any “()” vs “[]” concerns & eliminates a whole bunch of “()” or “[]” typing to initialize my arrays.