Data update

This commit is contained in:
Ingy dot Net 2024-04-19 16:56:29 -07:00
parent 0df55f9f24
commit aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions

View file

@ -0,0 +1,74 @@
BEGIN # draw some Cistercian Numerals #
INT ch = 6; # height of the representation of a Cistercian Numeral #
INT cw = 5; # width of the representation of a Cistercian Numeral #
INT cm = ( cw + 1 ) OVER 2; # mid-point of a line in the representation #
# of a Cistercian Numeral #
# returns a 5x6 CHAR array representing the Cistercian Nuneral of n #
# 0 <= m <= 9999 must be TRUE #
OP TOCISTERCIAN = ( INT n )[,]CHAR:
IF n < 0 OR n > 9999 THEN # invalid n #
( "?????", "?????", "?????", "?????", "?????", "?????" )
ELSE # n is OK #
# if ch isn't 6 or cw isn't 5, the strinngs above and below will #
[ 1 : ch, 1 : cw ]CHAR cn := # need to be adjusted #
( " ", " | ", " | ", " | ", " | ", " | " );
[]STRING t digits = ( #1# "__", #2# ";;__", #3# "; /;/"
, #4# ";\; \", #5# "__; /;/", #6# "; |; |"
, #7# "_; |; |", #8# "; |;_|", #9# "_; |;_|"
);
[]STRING b digits = ( #1# "__", #2# ";;__", #3# "\; \"
, #4# " /;/", #5# "_/;/", #6# " |; |"
, #7# "_|; |", #8# " |; |;_", #9# "_|; |;_"
);
# adds 1 digit to the numeral #
PROC add digit = ( INT digit, BOOL flip horizontal, flip vertical )VOID:
IF digit > 0 THEN # have a visible digit #
STRING d = IF flip vertical THEN b digits[ digit ] ELSE t digits[ digit ] FI;
INT x := IF flip horizontal THEN -1 ELSE 1 FI + cm;
INT y := IF flip vertical THEN ch ELSE 1 FI;
INT x init = x;
INT x step = IF flip horizontal THEN -1 ELSE 1 FI;
INT y step = IF flip vertical THEN -1 ELSE 1 FI;
FOR c pos FROM LWB d TO UPB d DO
CHAR c = d[ c pos ];
IF c = ";" THEN
y +:= y step;
x := x init
ELSE
cn[ y, x ] := IF ( flip horizontal XOR flip vertical ) THEN
IF c = "/" THEN "\" ELIF c = "\" THEN "/" ELSE c FI
ELSE c
FI;
x +:= x step
FI
OD
FI # add digit # ;
INT v := n;
add digit( v MOD 10, FALSE, FALSE ); v OVERAB 10;
add digit( v MOD 10, TRUE, FALSE ); v OVERAB 10;
add digit( v MOD 10, FALSE, TRUE ); v OVERAB 10;
add digit( v MOD 10, TRUE, TRUE );
cn
FI # TOCISTERCIAN # ;
# inserts a Cistercian Numeral representation of n into an set of lines #
PROC insert cistercian = ( [,]CHAR cn, REF[]STRING lines, INT pos )VOID:
FOR i FROM 1 TO ch DO
lines[ i ][ pos : ( pos + cw ) - 1 ] := STRING( cn[ i, : ] )
OD # print cistercian # ;
[]INT tests = ( 0, 20, 300, 4000, 5555, 6789, 1968 );
# construct an array of blank lines and insert the Cistercian Numereals #
[ 1 : ch ]STRING lines; # into them #
FOR i FROM LWB lines TO UPB lines DO
lines[ i ] := " " * ( ( ( UPB tests -LWB tests ) + 1 ) * ( cw * 2 ) )
OD;
FOR i FROM LWB tests TO UPB tests DO print( ( whole( tests[ i ], - cw ), " " * cw ) ) OD;
print( ( newline ) );
INT i pos := 1 - ( cw * 2 );
FOR i FROM LWB tests TO UPB tests DO
insert cistercian( TOCISTERCIAN tests[ i ], lines, i pos +:= cw * 2 )
OD;
FOR i FROM LWB lines TO UPB lines DO print( ( lines[ i ], newline ) ) OD
END

View file

@ -0,0 +1,84 @@
### Generic function
# Replace whatever is at .[$i:$i+1] with $x.
# The input and $x should be of the same type - strings or arrays.
def replace($i; $x): .[:$i] + $x + .[$i+1:];
### Cistercian numerals
# The canvas: an array of strings
def canvas:
(" " * 11) as $row
| [range(0; 15) | $row | replace(5; "x")];
def horiz($c1; $c2; $r):
reduce range($c1; $c2+1) as $c (.; .[$r] |= replace($c; "x"));
def verti($r1; $r2; $c):
reduce range($r1; $r2+1) as $r (.; .[$r] |= replace($c; "x"));
def diagd($c1; $c2; $r):
reduce range($c1; $c2+1) as $c (.; .[$r+$c-$c1] |= replace($c;"x"));
def diagu($c1; $c2; $r):
reduce range($c1; $c2+1) as $c (.; .[$r-$c+$c1] |= replace($c; "x"));
# input: the canvas
def draw($n):
if $n == 0 then .
elif $n == 1 then horiz(6; 10; 0)
elif $n == 2 then horiz(6; 10; 4)
elif $n == 3 then diagd(6; 10; 0)
elif $n == 4 then diagu(6; 10; 4)
elif $n == 5 then draw(1) | draw(4)
elif $n == 6 then verti(0; 4; 10)
elif $n == 7 then draw(1) | draw(6)
elif $n == 8 then draw(2) | draw(6)
elif $n == 9 then draw(1) | draw(8)
elif $n == 10 then horiz(0; 4; 0)
elif $n == 20 then horiz(0; 4; 4)
elif $n == 30 then diagu(0; 4; 4)
elif $n == 40 then diagd(0; 4; 0)
elif $n == 50 then draw(10) | draw(40)
elif $n == 60 then verti(0; 4; 0)
elif $n == 70 then draw(10) | draw(60)
elif $n == 80 then draw(20) | draw(60)
elif $n == 90 then draw(10) | draw(80)
elif $n == 100 then horiz(6; 10; 14)
elif $n == 200 then horiz(6; 10; 10)
elif $n == 300 then diagu(6; 10; 14)
elif $n == 400 then diagd(6; 10; 10)
elif $n == 500 then draw(100) | draw(400)
elif $n == 600 then verti(10; 14; 10)
elif $n == 700 then draw(100) | draw(600)
elif $n == 800 then draw(200) | draw(600)
elif $n == 900 then draw(100) | draw(800)
elif $n == 1000 then horiz(0; 4; 14)
elif $n == 2000 then horiz(0; 4; 10)
elif $n == 3000 then diagd(0; 4; 10)
elif $n == 4000 then diagu(0; 4; 14)
elif $n == 5000 then draw(1000) | draw(4000)
elif $n == 6000 then verti(10; 14; 0)
elif $n == 7000 then draw(1000) | draw(6000)
elif $n == 8000 then draw(2000) | draw(6000)
elif $n == 9000 then draw(1000) | draw(8000)
else "unable to draw \(.)" | error
end;
def cistercian:
(./1000|floor) as $thousands
| (. % 1000) as $n
| ($n/100|floor) as $hundreds
| ($n % 100) as $n
| ($n/10|floor) as $tens
| ($n % 10) as $ones
| "\(.):",
( canvas
| draw($thousands*1000)
| draw($hundreds*100)
| draw($tens*10)
| draw($ones)
| .[] ),
"" ;
0, 1, 20, 300, 4000, 5555, 6789, 9999
| cistercian