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,24 @@
with Ada.Text_IO;
procedure Cantor_Set is
subtype Level_Range is Integer range 1 .. 5;
Image : array (Level_Range) of String (1 .. 81) := (others => (others => ' '));
procedure Cantor (Level : Natural; Length : Natural; Start : Natural) is
begin
if Level in Level_Range then
Image (Level) (Start .. Start + Length - 1) := (others => '*');
Cantor (Level + 1, Length / 3, Start);
Cantor (Level + 1, Length / 3, Start + 2 * Length / 3);
end if;
end Cantor;
begin
Cantor (Level => Level_Range'First,
Length => 81,
Start => 1);
for L in Level_Range loop
Ada.Text_IO.Put_Line (Image (L));
end loop;
end Cantor_Set;

View file

@ -0,0 +1,38 @@
#include <stdio.h>
#define WIDTH 81
#define HEIGHT 5
char lines[HEIGHT][WIDTH];
void init() {
int i, j;
for (i = 0; i < HEIGHT; ++i) {
for (j = 0; j < WIDTH; ++j) lines[i][j] = '*';
}
}
void cantor(int start, int len, int index) {
int i, j, seg = len / 3;
if (seg == 0) return;
for (i = index; i < HEIGHT; ++i) {
for (j = start + seg; j < start + seg * 2; ++j) lines[i][j] = ' ';
}
cantor(start, seg, index + 1);
cantor(start + seg * 2, seg, index + 1);
}
void print() {
int i, j;
for (i = 0; i < HEIGHT; ++i) {
for (j = 0; j < WIDTH; ++j) printf("%c", lines[i][j]);
printf("\n");
}
}
int main() {
init();
cantor(0, WIDTH, 1);
print();
return 0;
}

View file

@ -0,0 +1,28 @@
#include <stdio.h>
#define WIDTH 81
int l, w, n, i;
void split (char* s)
{
l /= 3; n = 0;
do {
n += l; if (s[n] != ' ') for (i = 0; i < l; i++) s[n+i] = ' '; n += l+l;
} while (n < w);
}
void go (char* s)
{
puts (s); do { split (s); puts (s); } while (l > 1);
}
int main ()
{
char s[WIDTH+1];
l = w = WIDTH;
for (i = 0; i < WIDTH; i++) s[i] = '#'; s[WIDTH] = '\0'; go (s);
return (0);
}

View file

@ -0,0 +1,48 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. CANTOR.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SETTINGS.
03 NUM-LINES PIC 9 VALUE 5.
03 FILL-CHAR PIC X VALUE '#'.
01 VARIABLES.
03 CUR-LINE.
05 CHAR PIC X OCCURS 81 TIMES.
03 WIDTH PIC 99.
03 CUR-SIZE PIC 99.
03 POS PIC 99.
03 MAXPOS PIC 99.
03 NEXTPOS PIC 99.
03 I PIC 99.
PROCEDURE DIVISION.
BEGIN.
COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
PERFORM INIT.
MOVE WIDTH TO CUR-SIZE.
DISPLAY CUR-LINE.
PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
STOP RUN.
INIT.
PERFORM INIT-CHAR VARYING I FROM 1 BY 1
UNTIL I IS GREATER THAN WIDTH.
INIT-CHAR.
MOVE FILL-CHAR TO CHAR(I).
DO-LINE.
DIVIDE 3 INTO CUR-SIZE.
MOVE 1 TO POS.
SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
DISPLAY CUR-LINE.
BLANK-REGIONS.
ADD CUR-SIZE TO POS.
PERFORM BLANK-CHAR CUR-SIZE TIMES.
BLANK-CHAR.
MOVE SPACE TO CHAR(POS).
ADD 1 TO POS.

View file

@ -0,0 +1,29 @@
local WIDTH = 81
divert(-1)
changequote(`[',`]')
define([Cantor],[dnl
define([cantor],[C()
])dnl
define([line],[C()])dnl
define([C],[[C()C()C()]])dnl
define([_],[[_()_()_()]])dnl
Cantor_loop([$1])dnl
undefine([line])dnl
define([C],[*])dnl
define([_],[ ])dnl
cantor()dnl
undefine([C])dnl
undefine([_])dnl
undefine([cantor])dnl
])
define([Cantor_loop],[ifelse([$1],[0],,[dnl
pushdef([C],[[C()_()C()]])dnl
define([line],line)dnl
popdef([C])dnl
define([cantor],cantor()defn([line])
)dnl
Cantor_loop(decr([$1]))])])
divert(0)Cantor([4])

View file

@ -0,0 +1,17 @@
local n = 5
local w = 3 ^ (n - 1)
local len = w
local line = table.create(w)
for i = 1, w do line[i] = "#" end
while true do
print(line:concat(""))
if len == 1 then break end
len //= 3
local pos = 1
while pos < w - len do
pos += len
for i = pos, pos + len - 1 do line[i] = " " end
pos += len
end
end

View file

@ -0,0 +1,22 @@
(import srfi/231)
(define (kronecker-product A B)
(array-block (array-map (lambda (a) (array-map (lambda (b) (* a b)) B)) A)))
(define Cantor-base (list*->array 1 '(1)))
(define Cantor-iterate (list*->array 1 '(1 0 1)))
(define (do-Cantor levels)
(let loop ((l 0)
(C_l Cantor-base))
(if (<= l levels)
(begin
(array-for-each (lambda (entry)
(display (make-string (expt 3 (- levels l))
(if (positive? entry) #\* #\ ))))
C_l)
(newline)
(loop (+ l 1)
(kronecker-product Cantor-iterate C_l))))))
(do-Cantor 4)

View file

@ -0,0 +1,4 @@
[[0 81]]
P ← &p+@\s×3/↥⬚0≡(°⊚↘⊙⇡°⊟)
N ← ♭₂≡(⊟⇌⍜⊟⍉⊸+[⟜¯]÷3⊸/-)
P⍢(⊃P N|>1⊣⊢)