Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -1,9 +1,10 @@
procedure Array_Test is
A, B : array (1..20) of Integer;
type Example_Array_Type is array (1..20) of Integer;
A, B : Example_Array_Type;
-- Ada array indices may begin at any value, not just 0 or 1
C : array (-37..20) of integer
C : array (-37..20) of Integer;
-- Ada arrays may be indexed by enumerated types, which are
-- discrete non-numeric types
@ -26,7 +27,7 @@ procedure Array_Test is
Const : constant Arr := (1 .. 10 => 1, 11 .. 20 => 2, 21 | 22 => 3);
Centered : Arr (-50..50) := (0 => 1, Others => 0);
Result : Integer
Result : Integer;
begin
A := (others => 0); -- Assign whole array
@ -37,7 +38,7 @@ begin
A (3..5) := (2, 4, -1); -- Assign a constant slice
A (3..5) := A (4..6); -- It is OK to overlap slices when assigned
Fingers_Extended'First := False; -- Set first element of array
Fingers_Extended'Last := False; -- Set last element of array
Fingers_Extended(Fingers'First) := False; -- Set first element of array
Fingers_Extended(Fingers'Last) := False; -- Set last element of array
end Array_Test;

View file

@ -1,24 +1,24 @@
var .a1 = [1, 2, 3, "abc"]
val .a2 = series 4..10
val .a3 = .a1 ~ .a2
var a1 = [1, 2, 3, "abc"]
val a2 = series(4..10)
val a3 = a1 ~ a2
writeln "initial values ..."
writeln ".a1: ", .a1
writeln ".a2: ", .a2
writeln ".a3: ", .a3
writeln "a1: ", a1
writeln "a2: ", a2
writeln "a3: ", a3
writeln()
.a1[4] = .a2[4]
writeln "after setting .a1[4] = .a2[4] ..."
writeln ".a1: ", .a1
writeln ".a2: ", .a2
writeln ".a3: ", .a3
a1[4] = a2[4]
writeln "after setting a1[4] = a2[4] ..."
writeln "a1: ", a1
writeln "a2: ", a2
writeln "a3: ", a3
writeln()
writeln ".a2[1]: ", .a2[1]
writeln "a2[1]: ", a2[1]
writeln()
writeln "using index alternate ..."
writeln ".a2[5; 0]: ", .a2[5; 0]
writeln ".a2[10; 0]: ", .a2[10; 0]
writeln "a2[5; 0]: ", a2[5; 0]
writeln "a2[10; 0]: ", a2[10; 0]
writeln()

View file

@ -0,0 +1,19 @@
begin
// Static old-style arrays
var a: array [1..3] of integer := (1,2,3);
Println(a[1]);
// dynamic arrays - zero based indices
var a1: array of integer := new integer[3](1,3,5);
Println(a1[0]);
// dynamic arrays
var a2 := |1,3,5|; // literal array
SetLength(a2,4);
a2[^1] := 7; // "push" new value; ^1 - the first element from the end
// Lists are dynamically resizing arrays
var lst := new List<integer>(a1);
lst.Add(7);
Println(lst[^1]);
end.