Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -18,8 +18,11 @@ Please merge code in from these obsolete tasks:
:::*   [[Assigning Values to an Array]]
:::*   [[Retrieving an Element of an Array]]
;Related tasks:
*   [[Array]]
*   [[Vector]]
*   [[Sum and product of an array]]
*   [[Collections]]
*   [[Creating an Associative Array]]
*   [[Two-dimensional array (runtime)]]

View file

@ -1,20 +1,22 @@
PROC array_test = VOID:
(
[1:20]INT a;
a := others; # assign whole array #
a[1] := -1; # assign individual element #
a[3:5] := (2, 4, -1); # assign a slice #
[1:3]INT slice = a[3:5]; # copy a slice #
[1:10]INT a;
a := (1,2,3,4,5,6,7,8,9,10); # assign whole array #
a[1] := -1; # assign individual element #
[]INT slice = a[3:5]; # copy a slice #
a[3:5] := (2, 4, -1); # assign a slice #
REF []INT rslice = a[3:5]; # create a reference to a slice #
print((LWB rslice, UPB slice)); # query the bounds of the slice #
rslice := (2, 4, -1); # assign to the slice, modifying original array #
REF []INT rslice = a[3:5]; # create a reference to a slice #
print((LWB rslice, UPB rslice,newline)); # query the bounds of the slice #
rslice := (2, 4, -1); # assign to the slice, modifying original array #
print((slice,newline,rslice,newline,a[3:5],newline));
[1:3, 1:3]INT matrix; # create a two dimensional array #
REF []INT hvector = matrix[2,]; # create a reference to a row #
REF []INT vvector = matrix[,2]; # create a reference to a column #
REF [,]INT block = matrix[1:2, 1:2]; # create a reference to an area of the array #
[1:3, 1:3]INT matrix; # create a two dimensional array #
REF []INT hvector = matrix[2,]; # create a reference to a row #
REF []INT vvector = matrix[,2]; # create a reference to a column #
REF [,]INT block = matrix[1:2, 1:2]; # create a reference to an area of the array #
FLEX []CHAR string := "Hello, world!"; # create an array with variable bounds #
string := "shorter" # flexible arrays automatically resize themselves on assignment #
FLEX [1:13]CHAR string := "Hello, world!"; # create an array with variable bounds #
print((LWB string, UPB string,newline)); # query the bounds of the flexible array #
string := "shorter"; # flexible arrays automatically resize themselves on assignment #
print((LWB string, UPB string,newline)) # query the new bounds of the flexible array #
)

View file

@ -1,44 +0,0 @@
procedure Array_Test is
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;
-- Ada arrays may be indexed by enumerated types, which are
-- discrete non-numeric types
type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
type Activities is (Work, Fish);
type Daily_Activities is array(Days) of Activities;
This_Week : Daily_Activities := (Mon..Fri => Work, Others => Fish);
-- Or any numeric type
type Fingers is range 1..4; -- exclude thumb
type Fingers_Extended_Type is array(fingers) of Boolean;
Fingers_Extended : Fingers_Extended_Type;
-- Array types may be unconstrained. The variables of the type
-- must be constrained
type Arr is array (Integer range <>) of Integer;
Uninitialized : Arr (1 .. 10);
Initialized_1 : Arr (1 .. 20) := (others => 1);
Initialized_2 : Arr := (1 .. 30 => 2);
Const : constant Arr := (1 .. 10 => 1, 11 .. 20 => 2, 21 | 22 => 3);
Centered : Arr (-50..50) := (0 => 1, Others => 0);
Result : Integer;
begin
A := (others => 0); -- Assign whole array
B := (1 => 1, 2 => 1, 3 => 2, others => 0);
-- Assign whole array, different values
A (1) := -1; -- Assign individual element
A (2..4) := B (1..3); -- Assign a slice
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(Fingers'First) := False; -- Set first element of array
Fingers_Extended(Fingers'Last) := False; -- Set last element of array
end Array_Test;

View file

@ -1,14 +0,0 @@
#include <Array.au3> ;Include extended Array functions (_ArrayDisplay)
Local $aInputs[1] ;Create the Array with just 1 element
While True ;Endless loop
$aInputs[UBound($aInputs) - 1] = InputBox("Array", "Add one value") ;Save user input to the last element of the Array
If $aInputs[UBound($aInputs) - 1] = "" Then ;If an empty string is entered, then...
ReDim $aInputs[UBound($aInputs) - 1] ;...remove them from the Array and...
ExitLoop ;... exit the loop!
EndIf
ReDim $aInputs[UBound($aInputs) + 1] ;Add an empty element to the Array
WEnd
_ArrayDisplay($aInputs) ;Display the Array

View file

@ -1,39 +0,0 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. arrays.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 fixed-length-table.
03 fixed-table-elt PIC X OCCURS 5 TIMES.
01 table-length PIC 9(5) VALUE 1.
01 variable-length-table.
03 variable-table-elt PIC X OCCURS 1 TO 5 TIMES
DEPENDING ON table-length.
01 initial-value-area.
03 initial-values.
05 FILLER PIC X(10) VALUE "One".
05 FILLER PIC X(10) VALUE "Two".
05 FILLER PIC X(10) VALUE "Three".
03 initial-value-table REDEFINES initial-values.
05 initial-table-elt PIC X(10) OCCURS 3 TIMES.
01 indexed-table.
03 indexed-elt PIC X OCCURS 5 TIMES
INDEXED BY table-index.
PROCEDURE DIVISION.
*> Assigning the contents of an entire table.
MOVE "12345" TO fixed-length-table
*> Indexing an array (using an index)
MOVE 1 TO table-index
MOVE "1" TO indexed-elt (table-index)
*> Pushing a value into a variable-length table.
ADD 1 TO table-length
MOVE "1" TO variable-table-elt (2)
GOBACK
.

View file

@ -1,29 +0,0 @@
--Arrays task for Rosetta Code wiki
--User:Lnettnay
atom dummy
--Arrays are sequences
-- single dimensioned array of 10 elements
sequence xarray = repeat(0,10)
xarray[5] = 5
dummy = xarray[5]
? dummy
--2 dimensional array
--5 sequences of 10 elements each
sequence xyarray = repeat(repeat(0,10),5)
xyarray[3][6] = 12
dummy = xyarray[3][6]
? dummy
--dynamic array use (all sequences can be modified at any time)
sequence dynarray = {}
for x = 1 to 10 do
dynarray = append(dynarray, x * x)
end for
? dynarray
for x = 1 to 10 do
dynarray = prepend(dynarray, x)
end for
? dynarray

View file

@ -1,22 +0,0 @@
class Main {
static public function main():Void {
// Array (dynamic length)
var a = new Array<Int>();
for (i in 1...4)
a.push(i);
// alt: var a = [1, 2, 3];
// alt2: var a = [for (i in 1...4)];
for (i in 0...a.length)
trace(a[i]);
// Vector (fixed-length)
var v = new haxe.ds.Vector(3);
v[0] = 1;
v[1] = 2;
v[2] = 3;
for (i in 0...v.length)
trace(v[i]);
}
}

View file

@ -1,5 +1,6 @@
REM As far as I know, there is no way to have dynamic arrays.
PROC main:
REM Declare an integer array of 10 elements and a string array of 10 elements, each up to 12 characters long.
LOCAL array1%(10),array2$(10,12)
REM Array element count starts at 1.
array1%(1)=128

View file

@ -1 +0,0 @@
$a = @()

View file

@ -1,2 +0,0 @@
$a = ,2
$a = @(2) # alternative

View file

@ -1 +0,0 @@
$a = 1,2,3

View file

@ -1 +0,0 @@
$a += 5

View file

@ -1 +0,0 @@
$a[1]

View file

@ -1 +0,0 @@
$a[1] = 42

View file

@ -1 +0,0 @@
$r = 1..100

View file

@ -1 +0,0 @@
$r[0..9+25..27+80,85,90]

View file

@ -1 +0,0 @@
$r[-1] # last index

View file

@ -1,2 +0,0 @@
a: [] ; Empty.
b: ["foo"] ; Pre-initialized.

View file

@ -1,2 +0,0 @@
append a ["up" "down"] ; -> ["up" "down"]
insert a [left right] ; -> [left right "up" "down"]

View file

@ -1,4 +0,0 @@
first a ; -> left
third a ; -> "up"
last a ; -> "down"
a/2 ; -> right (Note: REBOL is 1-based.)

View file

@ -1,10 +0,0 @@
a ; -> [left right "up" "down"]
next a ; -> [right "up" "down"]
skip a 2 ; -> ["up" "down"]
a: next a ; -> [right "up" "down"]
head a ; -> [left right "up" "down"]
copy a ; -> [left right "up" "down"]
copy/part a 2 ; -> [left right]
copy/part skip a 2 2 ; -> ["up" "down"]

View file

@ -1,11 +1,9 @@
-- 7 Aug 2025
include Settings
-- 23 Aug 2025
include Setting
say 'ARRAYS'
say 'ARRAYS BASIC USAGE'
say version
say
if Pos('Regina',version) > 0 then
call Library
say 'Simple array...'
do i = 1 to 10
a.i=i*i
@ -17,49 +15,7 @@ say 'Mimic indexing...'
say 'Square of' 3 'is' a(3)
say 'Square of' 7 'is' a(7)
say
say 'A default value...'
b. = 'Out of range'
do i = 1 to 10
b.i=1/i
end
say 'Inverse of' 3 'is' b.3
say 'Inverse of' 7 'is' b.7
say 'Inverse of' 11 'is' b.11
say
say 'Index zero...'
do i = 1 to 10
c.i=i*i*i
end
c.0=10
j=0; say 'Number of rows is' c.j
j=3; say 'Cube of' j 'is' c.j
j=7; say 'Cube of' j 'is' c.j
say
say 'Sparse array...'
d.=0
do i = 3 by 3 to 9
d.i=-i
end
say 'Negative of' 3 'is' d.3
say 'Negative of' 7 'is' d.7
say
say 'More dimensions...'
e.=0
do i = 1 to 3
do j = 1 to 3
e.i.j=i*j
end
end
say '1x2 is' e.1.2
say '3x2 is' e.3.2
say
call SysDumpVariables
say
say 'Element has no value...'
signal off novalue
say 'f.notassigned =' f.notassigned
signal on novalue name Abend
say 'f.notassigned =' f.notassigned
call DumpVariables
exit
A:
@ -67,11 +23,4 @@ procedure expose a.
arg xx
return a.xx
Library:
say 'Library...'
call RxFuncAdd 'SysLoadFuncs','RegUtil','SysLoadFuncs'
call SysLoadFuncs
say
return
include Abend
include Math

View file

@ -1,7 +0,0 @@
let arr = [1, 2, 3]
let _ = Js.Array2.push(arr, 4)
arr[3] = 5
Js.log(Js.Int.toString(arr[3]))

View file

@ -1,45 +0,0 @@
'Arrays - VBScript - 08/02/2021
'create a static array
Dim a(3) ' 4 items : a(0), a(1), a(2), a(3)
'assign a value to elements
For i = 1 To 3
a(i) = i * i
Next
'and retrieve elements
buf=""
For i = 1 To 3
buf = buf & a(i) & " "
Next
WScript.Echo buf
'create a dynamic array
Dim d()
ReDim d(3) ' 4 items : d(0), d(1), d(2), d(3)
For i = 1 To 3
d(i) = i * i
Next
buf=""
For i = 1 To 3
buf = buf & d(i) & " "
Next
WScript.Echo buf
d(0) = 0
'expand the array and preserve existing values
ReDim Preserve d(4) ' 5 items : d(0), d(1), d(2), d(3), d(4)
d(4) = 16
buf=""
For i = LBound(d) To UBound(d)
buf = buf & d(i) & " "
Next
WScript.Echo buf
'create and initialize an array dynamicaly
b = Array(1, 4, 9)
'and retrieve all elements
WScript.Echo Join(b,",")
'Multi-Dimensional arrays
'The following creates a 5x4 matrix
Dim mat(4,3)

View file

@ -1,57 +0,0 @@
entity Array_Test is
end entity Array_Test;
architecture Example of Array_test is
-- Array type have to be defined first
type Integer_Array is array (Integer range <>) of Integer;
-- Array index range can be ascending...
signal A : Integer_Array (1 to 20);
-- or descending
signal B : Integer_Array (20 downto 1);
-- VHDL array index ranges may begin at any value, not just 0 or 1
signal C : Integer_Array (-37 to 20);
-- VHDL arrays may be indexed by enumerated types, which are
-- discrete non-numeric types
type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
type Activities is (Work, Fish);
type Daily_Activities is array (Days) of Activities;
signal This_Week : Daily_Activities := (Mon to Fri => Work, Others => Fish);
type Finger is range 1 to 4; -- exclude thumb
type Fingers_Extended is array (Finger) of Boolean;
signal Extended : Fingers_Extended;
-- Array types may be unconstrained.
-- Objects of the type must be constrained
type Arr is array (Integer range <>) of Integer;
signal Uninitialized : Arr (1 to 10);
signal Initialized_1 : Arr (1 to 20) := (others => 1);
constant Initialized_2 : Arr := (1 to 30 => 2);
constant Const : Arr := (1 to 10 => 1, 11 to 20 => 2, 21 | 22 => 3);
signal Centered : Arr (-50 to 50) := (0 => 1, others => 0);
signal Result : Integer;
begin
A <= (others => 0); -- Assign whole array
B <= (1 => 1, 2 => 1,
3 => 2, others => 0); -- Assign whole array, different values
A (1) <= -1; -- Assign individual element
A (2 to 4) <= B (3 downto 1); -- Assign a slice
A (3 to 5) <= (2, 4, -1); -- Assign an aggregate
A (3 to 5) <= A (4 to 6); -- It is OK to overlap slices when assigned
-- VHDL arrays does not have 'first' and 'last' elements,
-- but have 'Left' and 'Right' instead
Extended (Extended'Left) <= False; -- Set leftmost element of array
Extended (Extended'Right) <= False; -- Set rightmost element of array
Result <= A (A'Low) + B (B'High);
end architecture Example;