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

@ -1,66 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Range_Expansion is
type Sequence is array (Positive range <>) of Integer;
function Expand (Text : String) return Sequence is
To : Integer := Text'First;
Count : Natural := 0;
Low : Integer;
function Get return Integer is
From : Integer := To;
begin
if Text (To) = '-' then
To := To + 1;
end if;
while To <= Text'Last loop
case Text (To) is
when ',' | '-' => exit;
when others => To := To + 1;
end case;
end loop;
return Integer'Value (Text (From..To - 1));
end Get;
begin
while To <= Text'Last loop -- Counting items of the list
Low := Get;
if To > Text'Last or else Text (To) = ',' then
Count := Count + 1;
else
To := To + 1;
Count := Count + Get - Low + 1;
end if;
To := To + 1;
end loop;
return Result : Sequence (1..Count) do
Count := 0;
To := Text'First;
while To <= Text'Last loop -- Filling the list
Low := Get;
if To > Text'Last or else Text (To) = ',' then
Count := Count + 1;
Result (Count) := Low;
else
To := To + 1;
for Item in Low..Get loop
Count := Count + 1;
Result (Count) := Item;
end loop;
end if;
To := To + 1;
end loop;
end return;
end Expand;
procedure Put (S : Sequence) is
First : Boolean := True;
begin
for I in S'Range loop
if First then
First := False;
else
Put (',');
end if;
Put (Integer'Image (S (I)));
end loop;
end Put;
begin
Put (Expand ("-6,-3--1,3-5,7-11,14,15,17-20"));
end Test_Range_Expansion;

View file

@ -1,7 +1,7 @@
expandRange: function [rng][
flatten @ to :block
join.with:" " map split.by:"," rng 'x ->
replace replace replace x
"@" ++ replace replace replace x
{/^\-(\d+)/} "(neg $1)" {/\-\-(\d+)/}
"-(neg $1)" "-" ".."
]

View file

@ -1,93 +0,0 @@
>>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. expand-range.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 comma-pos PIC 99 COMP VALUE 1.
01 dash-pos PIC 99 COMP.
01 end-num PIC S9(3).
01 Max-Part-Len CONSTANT 10.
01 num PIC S9(3).
01 edited-num PIC -(3)9.
01 part PIC X(10).
01 part-flag PIC X.
88 last-part VALUE "Y".
01 range-str PIC X(80).
01 Range-Str-Len CONSTANT 80.
01 start-pos PIC 99 COMP.
01 start-num PIC S9(3).
PROCEDURE DIVISION.
ACCEPT range-str
PERFORM WITH TEST AFTER UNTIL last-part
UNSTRING range-str DELIMITED BY "," INTO part WITH POINTER comma-pos
PERFORM check-if-last
PERFORM find-range-dash
IF dash-pos > Max-Part-Len
PERFORM display-num
ELSE
PERFORM display-range
END-IF
END-PERFORM
DISPLAY SPACES
GOBACK
.
check-if-last SECTION.
IF comma-pos > Range-Str-Len
SET last-part TO TRUE
END-IF
.
find-range-dash SECTION.
IF part (1:1) <> "-"
MOVE 1 TO start-pos
ELSE
MOVE 2 TO start-pos
END-IF
MOVE 1 TO dash-pos
INSPECT part (start-pos:) TALLYING dash-pos FOR CHARACTERS BEFORE "-"
COMPUTE dash-pos = dash-pos + start-pos - 1
.
display-num SECTION.
MOVE part TO edited-num
CALL "display-edited-num" USING CONTENT part-flag, edited-num
.
display-range SECTION.
MOVE part (1:dash-pos - 1) TO start-num
MOVE part (dash-pos + 1:) TO end-num
PERFORM VARYING num FROM start-num BY 1 UNTIL num = end-num
MOVE num TO edited-num
CALL "display-edited-num" USING CONTENT "N", edited-num
END-PERFORM
MOVE end-num TO edited-num
CALL "display-edited-num" USING CONTENT part-flag, edited-num
.
END PROGRAM expand-range.
IDENTIFICATION DIVISION.
PROGRAM-ID. display-edited-num.
DATA DIVISION.
LINKAGE SECTION.
01 hide-comma-flag PIC X.
88 hide-comma VALUE "Y".
01 edited-num PIC -(3)9.
PROCEDURE DIVISION USING hide-comma-flag, edited-num.
DISPLAY FUNCTION TRIM(edited-num) NO ADVANCING
IF NOT hide-comma
DISPLAY ", " NO ADVANCING
END-IF
.
END PROGRAM display-edited-num.

View file

@ -1,22 +0,0 @@
function range-expansion($array) {
function expansion($arr) {
if($arr) {
$arr = $arr.Split(',')
$arr | foreach{
$a = $_
$b, $c, $d, $e = $a.Split('-')
switch($a) {
$b {return $a}
"-$c" {return $a}
"$b-$c" {return "$(([Int]$b)..([Int]$c))"}
"-$c-$d" {return "$(([Int]$("-$c"))..([Int]$d))"}
"-$c--$e" {return "$(([Int]$("-$c"))..([Int]$("-$e")))"}
}
}
} else {""}
}
$OFS = ", "
"$(expansion $array)"
$OFS = " "
}
range-expansion "-6,-3--1,3-5,7-11,14,15,17-20"

View file

@ -1,42 +0,0 @@
function Expand-Range
{
[CmdletBinding()]
[OutputType([int])]
Param
(
[Parameter(Mandatory=$true,
Position=0)]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[0-9,-]*$')]
[string]
$Range
)
try
{
if ($Range -match '-,') # I'm not good enough to weed this case out with Regex
{
throw "Input string was not in a correct format."
}
[int[]]$output = $Range -split ',' | ForEach-Object {
[int[]]$array = $_ -split '(?<=\d)-'
if ($array.Count -gt 1) # $array contains one or two elements
{
$array[0]..$array[1] # two elements = start and end of range
}
else
{
$array # one element = an integer
}
}
}
catch
{
throw "Input string was not in a correct format."
}
$output
}

View file

@ -1 +0,0 @@
(Expand-Range "-6,-3--1,3-5,7-11,14,15,17-20") -join ", "