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,26 +0,0 @@
with Ada.Text_IO;
procedure Nth is
function Suffix(N: Natural) return String is
begin
if N mod 10 = 1 and then N mod 100 /= 11 then return "st";
elsif N mod 10 = 2 and then N mod 100 /= 12 then return "nd";
elsif N mod 10 = 3 and then N mod 100 /= 13 then return "rd";
else return "th";
end if;
end Suffix;
procedure Print_Images(From, To: Natural) is
begin
for I in From .. To loop
Ada.Text_IO.Put(Natural'Image(I) & Suffix(I));
end loop;
Ada.Text_IO.New_Line;
end Print_Images;
begin
Print_Images( 0, 25);
Print_Images( 250, 265);
Print_Images(1000, 1025);
end Nth;

View file

@ -1,10 +1,10 @@
suffixes: ["th" "st" "nd" "rd" "th" "th" "th" "th" "th" "th"]
nth: function [n][
if? or? 100 >= n%100
20 < n%100
-> (to :string n) ++ "'" ++ suffixes\[n%10]
else -> (to :string n) ++ "'th"
switch or? 100 >= n%100
20 < n%100
-> (to :string n) ++ "'" ++ suffixes\[n%10]
-> (to :string n) ++ "'th"
]
loop range.step:250 0 1000 'j [

View file

@ -11,14 +11,11 @@ exit /b
setlocal enabledelayedexpansion
for /l %%n in (%~1,1,%~2) do (
set curr_num=%%n
if !curr_num:~-2!==11 (set "out=%%nth"
) else if !curr_num:~-2!==12 (set "out=%%nth"
) else if !curr_num:~-2!==13 (set "out=%%nth"
) else if !curr_num:~-1!==1 (set "out=%%nst"
) else if !curr_num:~-1!==2 (set "out=%%nnd"
) else if !curr_num:~-1!==3 (set "out=%%nrd"
) else (set "out=%%nth")
if !curr_num:~-1!==1 (set "out=%%nst"
) else if !curr_num:~-1!==2 (set "out=%%n'nd"
) else if !curr_num:~-1!==3 (set "out=%%n'rd"
) else (set "out=%%n'th")
set "range_output=!range_output! !out!"
)
echo."!range_output:~1!"
echo:"!range_output:~1!"
goto :EOF

View file

@ -1,31 +0,0 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. NTH-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUMBER.
05 N PIC 9(8).
05 LAST-TWO-DIGITS PIC 99.
05 LAST-DIGIT PIC 9.
05 N-TO-OUTPUT PIC Z(7)9.
05 SUFFIX PIC AA.
PROCEDURE DIVISION.
TEST-PARAGRAPH.
PERFORM NTH-PARAGRAPH VARYING N FROM 0 BY 1 UNTIL N IS GREATER THAN 25.
PERFORM NTH-PARAGRAPH VARYING N FROM 250 BY 1 UNTIL N IS GREATER THAN 265.
PERFORM NTH-PARAGRAPH VARYING N FROM 1000 BY 1 UNTIL N IS GREATER THAN 1025.
STOP RUN.
NTH-PARAGRAPH.
MOVE 'TH' TO SUFFIX.
MOVE N (7:2) TO LAST-TWO-DIGITS.
IF LAST-TWO-DIGITS IS LESS THAN 4,
OR LAST-TWO-DIGITS IS GREATER THAN 20,
THEN PERFORM DECISION-PARAGRAPH.
MOVE N TO N-TO-OUTPUT.
DISPLAY N-TO-OUTPUT WITH NO ADVANCING.
DISPLAY SUFFIX WITH NO ADVANCING.
DISPLAY SPACE WITH NO ADVANCING.
DECISION-PARAGRAPH.
MOVE N (8:1) TO LAST-DIGIT.
IF LAST-DIGIT IS EQUAL TO 1 THEN MOVE 'ST' TO SUFFIX.
IF LAST-DIGIT IS EQUAL TO 2 THEN MOVE 'ND' TO SUFFIX.
IF LAST-DIGIT IS EQUAL TO 3 THEN MOVE 'RD' TO SUFFIX.

View file

@ -13,17 +13,17 @@ extension op
};
(i.mod(10)) =>
1 { ^ i.toPrintable() + "st" }
2 { ^ i.toPrintable() + "nd" }
3 { ^ i.toPrintable() + "rd" };
1 : { ^ i.toPrintable() + "st" }
2 : { ^ i.toPrintable() + "nd" }
3 : { ^ i.toPrintable() + "rd" };
^ i.toPrintable() + "th"
}
}
public program()
public Program()
{
console.printLine(new Range(0,26).selectBy(mssgconst ordinalize<op>[1]));
console.printLine(new Range(250,26).selectBy(mssgconst ordinalize<op>[1]));
console.printLine(new Range(1000,26).selectBy(mssgconst ordinalize<op>[1]))
Console.printLine(new Range(0,26).selectBy(mssgconst ordinalize<op>[1]));
Console.printLine(new Range(250,26).selectBy(mssgconst ordinalize<op>[1]));
Console.printLine(new Range(1000,26).selectBy(mssgconst ordinalize<op>[1]))
}

View file

@ -1,28 +1,21 @@
CFStringRef local fn Suffix( n as int )
if ( n % 100 / 10 == 1 ) then exit fn
select ( n % 10 )
case 1 : return @"st"
case 2 : return @"nd"
case 3 : return @"rd"
end select
end fn = @"th"
CFStringRef local fn ordinalSuffix( num as int )
num = ( num % 100 / 10 - 1 ) ? num % 10 * 2 : 0
end fn = mid( @"thstndrdththththththth", num, 2 )
void local fn DoIt
int i
for i = 0 to 25
print i;fn Suffix(i);@" ";
next
print
for i = 250 to 265
print i;fn Suffix(i);@" ";
next
print
for i = 1000 to 1025
print i;fn Suffix(i);@" ";
void local fn show( min as int, max as int )
int sz = len( str(max) ) + 2, count = 54 / sz
CFStringRef f = concat( @"%", mid( str( sz ), 1 ), @"d%@\b" )
for int i = min to max
printf f, i, fn OrdinalSuffix( i )
if !( ( i + 1 - min ) % count ) then print
next
print @"\n"
end fn
fn DoIt
// DEMO //
fn show( 0, 25 )
fn show( 250, 265 )
fn show( 1000, 1025 )
HandleEvents
handleevents

View file

@ -1,6 +1,6 @@
(function ordinal n
(if ([11 12 13] (rem n 100))
(str n "th")
"{n}th"
(str n (or ((rem n 10) ["th" "st" "nd" "rd"]) "th"))))
(function line x y

View file

@ -1,21 +0,0 @@
function nth($inp){
$suffix = "th"
switch($inp % 100){
11{$suffix="th"}
12{$suffix="th"}
13{$suffix="th"}
default{
switch($inp % 10){
1{$suffix="st"}
2{$suffix="nd"}
3{$suffix="rd"}
}
}
}
return "$inp$suffix "
}
0..25 | %{Write-host -nonewline (nth "$_")};""
250..265 | %{Write-host -nonewline (nth "$_")};""
1000..1025 | %{Write-host -nonewline (nth "$_")};""

View file

@ -1,23 +0,0 @@
function Get-Nth ([int]$Number)
{
$suffix = "th"
switch ($Number % 100){
11 {$suffix = "th"}
12 {$suffix = "th"}
13 {$suffix = "th"}
default {
switch ($Number % 10){
1 {$suffix = "st"}
2 {$suffix = "nd"}
3 {$suffix = "rd"}
}
}
}
"$Number$suffix"
}
1..25 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force
251..265 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force
1001..1025 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force