Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,11 @@
procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;

View file

@ -0,0 +1,12 @@
procedure Array_Collection is
type Array_Type is array (1 .. 3) of Integer;
A : Array_Type := (1, 2, 3);
begin
A (1) := 3;
A (2) := 2;
A (3) := 1;
end Array_Collection;

View file

@ -0,0 +1,13 @@
procedure Array_Collection is
type Array_Type is array (positive range <>) of Integer; -- may be indexed with any positive
-- Integer value
A : Array_Type(1 .. 3); -- creates an array of three integers, indexed from 1 to 3
begin
A (1) := 3;
A (2) := 2;
A (3) := 1;
end Array_Collection;

View file

@ -0,0 +1,17 @@
with Ada.Containers.Doubly_Linked_Lists;
use Ada.Containers;
procedure Doubly_Linked_List is
package DL_List_Pkg is new Doubly_Linked_Lists (Integer);
use DL_List_Pkg;
DL_List : List;
begin
DL_List.Append (1);
DL_List.Append (2);
DL_List.Append (3);
end Doubly_Linked_List;

View file

@ -0,0 +1,17 @@
with Ada.Containers.Vectors;
use Ada.Containers;
procedure Vector_Example is
package Vector_Pkg is new Vectors (Natural, Integer);
use Vector_Pkg;
V : Vector;
begin
V.Append (1);
V.Append (2);
V.Append (3);
end Vector_Example;

View file

@ -0,0 +1,37 @@
identification division.
program-id. collections.
data division.
working-storage section.
01 sample-table.
05 sample-record occurs 1 to 3 times depending on the-index.
10 sample-alpha pic x(4).
10 filler pic x value ":".
10 sample-number pic 9(4).
10 filler pic x value space.
77 the-index usage index.
procedure division.
collections-main.
set the-index to 3
move 1234 to sample-number(1)
move "abcd" to sample-alpha(1)
move "test" to sample-alpha(2)
move 6789 to sample-number(3)
move "wxyz" to sample-alpha(3)
display "sample-table : " sample-table
display "sample-number(1): " sample-number(1)
display "sample-record(2): " sample-record(2)
display "sample-number(3): " sample-number(3)
*> abend: out of bounds subscript, -debug turns on bounds check
set the-index down by 1
display "sample-table : " sample-table
display "sample-number(3): " sample-number(3)
goback.
end program collections.

View file

@ -0,0 +1,47 @@
# Create an Array by separating the elements with commas:
$array = "one", 2, "three", 4
# Using explicit syntax:
$array = @("one", 2, "three", 4)
# Send the values back into individual variables:
$var1, $var2, $var3, $var4 = $array
# An array of several integer ([int]) values:
$array = 0, 1, 2, 3, 4, 5, 6, 7
# Using the range operator (..):
$array = 0..7
# Strongly typed:
[int[]] $stronglyTypedArray = 1, 2, 4, 8, 16, 32, 64, 128
# An empty array:
$array = @()
# An array with a single element:
$array = @("one")
# I suppose this would be a jagged array:
$jaggedArray = @((11, 12, 13),
(21, 22, 23),
(31, 32, 33))
$jaggedArray | Format-Wide {$_} -Column 3 -Force
$jaggedArray[1][1] # returns 22
# A Multi-dimensional array:
$multiArray = New-Object -TypeName "System.Object[,]" -ArgumentList 6,6
for ($i = 0; $i -lt 6; $i++)
{
for ($j = 0; $j -lt 6; $j++)
{
$multiArray[$i,$j] = ($i + 1) * 10 + ($j + 1)
}
}
$multiArray | Format-Wide {$_} -Column 6 -Force
$multiArray[2,2] # returns 33

View file

@ -0,0 +1,46 @@
# An empty Hash Table:
$hash = @{}
# A Hash table populated with some values:
$nfcCentralDivision = @{
Packers = "Green Bay"
Bears = "Chicago"
Lions = "Detroit"
}
# Add items to a Hash Table:
$nfcCentralDivision.Add("Vikings","Minnesota")
$nfcCentralDivision.Add("Buccaneers","Tampa Bay")
# Remove an item from a Hash Table:
$nfcCentralDivision.Remove("Buccaneers")
# Searching for items
$nfcCentralDivision.ContainsKey("Packers")
$nfcCentralDivision.ContainsValue("Green Bay")
# A bad value...
$hash1 = @{
One = 1
Two = 3
}
# Edit an item in a Hash Table:
$hash1.Set_Item("Two",2)
# Combine Hash Tables:
$hash2 = @{
Three = 3
Four = 4
}
$hash1 + $hash2
# Using the ([ordered]) accelerator the items in the Hash Table retain the order in which they were input:
$nfcCentralDivision = [ordered]@{
Bears = "Chicago"
Lions = "Detroit"
Packers = "Green Bay"
Vikings = "Minnesota"
}

View file

@ -0,0 +1,9 @@
$list = New-Object -TypeName System.Collections.ArrayList -ArgumentList 1,2,3
# or...
$list = [System.Collections.ArrayList]@(1,2,3)
$list.Add(4) | Out-Null
$list.RemoveAt(2)

View file

@ -0,0 +1,2 @@
var 'data ref { }
append! { 1 2 3 } 'data

View file

@ -0,0 +1,20 @@
# Arrays are at the heart of Uiua, so lots to see here.
⇡6 # Range -> [0 1 2 3 4 5]
⇌ # Reverse -> [5 4 3 2 1 0]
⊂123 # Join -> [123 5 4 3 2 1 0]
˜⊂99 # Backjoin -> [123 5 4 3 2 1 0 99]
≡(+2) # Operate on every element -> [125 7 6 5 4 3 2 101]
-2 # Many operations are 'pervasive' i.e. act on every element at once.
# Destructive operations.
# ⟜(&p[⊃(..|..|...)]) means 'perform all ops on same data, collect results as array, print, restore original data'.
⟜(&p[⊃(⧻|⊢|⊣|⊡1|⊡¯2)]) # Access: len, first, last, second, second-from-end. Print -> [8 123 99 5 0]
⟜(&p[⊃(/+|/×|/↧|/↥)]) # Reduce: sum, product, min, max. Print -> [237 0 0 123]
⟜(&p[⊃(˜∊99|˜⨂99)]) # Membership, location. Print -> [1 7] (1 = true)
# Grouping
⟜(&p⊕□⊸◿2) # Group by odd/even -> [[4 2 0] [123 5 3 1 99]]
&p⊜□⊸>₂ # Partition(split) wherever element is <2 -> [123 5 4 3│99]
# So... split on space, get length of each word, find max, get that word.
°□⊡˜⨂⊸/↥⊸≡◇⧻⊜□⊸≠@\s "This is the longest word"