elementslooks like it could be an array. But more likely a list. Some methods you've listed may or may not exists without having to add extra code. Some of what you describe is available "out of the box" more can be had by adding another library. Spring4d (open source) is an excellent example. The way the exercises are setup I think you will find you will not have to go too old school. Though you are welcome too, and if you do I'll point out better ways to accomplish the same task, if I am mentoring your work.
inline declaration and type inference is also available starting with Delphi 10.3.
var elements: TArray<integer> := [3,4,5,6,7,8,9,10];
myArray would be of type
var myList := TList<integer>.create; myList.AddRange([3,4,5,6,7,8,9,10]); // do some stuff with myList...... var myArray := myList.ToArray;
myArrayand didn't care about an index you do so with a
forloop like so:
for var myInteger in myArray do begin // Do something with myInteger.... end;
Trying out the Grains sample from the extended exercises, I'm struggling to get around an overflow condition within the method which computes the number of grains on square 64. The series is a progression computed by 2^(n-1) as far as I can tell (where n is the number of the square), so for square 64 the value should be 2^63 ... However, when executing the test for this particular instance, I'm getting the exception 'floating point invalid operation', although for all previous tests, the code is working fine.
Code is here:
Class Function Grains.square(n: Integer = 1): UInt64; begin result := Round(Ldexp(1, n-1)); end;
Xin the corner. If you are able to run a basic program like I just described then I recommend reviewing the DUnitX setup steps to make sure you didn't miss anything.
case i of 128..255: begin // Do Stuff Here end; 0..127: begin // Do Different Stuff Here end; end;