Dynamic arrays can be ragged arrays. I gave an example on this forum some time ago.
Simplest example:Needs FPC 3.2.0 or higher.
{$mode delphi} var a:array of array of integer; begin a:= [[1,2,3,4],[1,2,3]]; // now 4 X 3, rectangular a[1] := [4,5]; // change 1 element to 2 instead of three: ragged, no longer rectangular end.
You can build infinitely complex structures using this technique. Does that help?
In this example, I don't understand how is a rectangular in the first place?!
a:= [[1,2,3,4],[1,2,3]];
Well , that's disappointing because it shows an arbitrary array that I understood what OP meant.
In this example, I don't understand how is a rectangular in the first place?!
In this example, I don't understand how is a rectangular in the first place?!
The line:Code: [Select]a:= [[1,2,3,4],[1,2,3]];
creates an array of 4 rows, 3 columns per row (or viceversa ;)); i.e. a rectangular array, as if it had been declared as:
a: array[0..3, 0..2] of Integer;
It was announced in May, 2018 in (where else? :)) the fpc-anounce mailing list (https://lists.freepascal.org/pipermail/fpc-announce/2018-May/000606.html) and extensively discused in fpc-pascal (https://lists.freepascal.org/pipermail/fpc-pascal/2018-May/053892.html)
But no, according to this announcement, it will be what I thought in the first place -- it will allocate 4+3 = 7 integers (and initialize them to given values). It will not allocate 4 * 3 = 12 integers.
So, the array was not rectangular in the first place.
Ragged array like this is not what I means and I myself think it ugly. When people from JVM based language background said data structure he means Classes.
I think he means something like Tuples in some languages. It is not an original java or C# feature, but one that was added later because their VMs got it added for other functional and/or scripting languages.Please close this thread. Everyone misunderstood me and I confused everyone :(
And while you can emulate it with arrays of variants to some agree (and TDataset etc does), the scripting like language level syntax is not there. And hopefully never comes.
If you want a scripting language, may I suggest Python?
Please close this thread. Everyone misunderstood me and I confused everyone :(But please don't edit your initial post to remove the question, cause now nobody knows what everyone answered to.
Then delete this thread altogether. It's a useless offtopic bulshit 8-)Please close this thread. Everyone misunderstood me and I confused everyone :(But please don't edit your initial post to remove the question, cause now nobody knows what everyone answered to.
Please close this thread. Everyone misunderstood me and I confused everyone :(But please don't edit your initial post to remove the question, cause now nobody knows what everyone answered to.
I'm a fantom language hobbyist fan and I have used it to do many small homework kindof exercises. My algorithms sucks and my App all very slow and memory hundry but at least worksand give the correct answer. I used to use listof a list of a list and return a list kind of thing. Fantom allowed me to do such thing. I knowit's bad practice but I wonder if I could do the same in Pascal? Is there any limitations?The JVM which Fantom utilize allows me to do incredible things
Ex: lst1 = [1, 2, 3]
lst2 = [4, 5,6]
lst3 = [[lst1], [lst2]]
Function ftake lst3 as input and return lst4 also a list as output.
It's a simple case. There's manymore insane things :D