Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,43 @@
MODULE Cell EXPORTS Main;
IMPORT IO, Fmt, Word;
VAR culture := ARRAY [0..19] OF INTEGER {0, 1, 1, 1,
0, 1, 1, 0,
1, 0, 1, 0,
1, 0, 1, 0,
0, 1, 0, 0};
PROCEDURE Step(VAR culture: ARRAY OF INTEGER) =
VAR left: INTEGER := 0;
this, right: INTEGER;
BEGIN
FOR i := FIRST(culture) TO LAST(culture) - 1 DO
right := culture[i + 1];
this := culture[i];
culture[i] :=
Word.Or(Word.And(this, Word.Xor(left, right)), Word.And(Word.Not(this), Word.And(left, right)));
left := this;
END;
culture[LAST(culture)] := Word.And(culture[LAST(culture)], Word.Not(left));
END Step;
PROCEDURE Put(VAR culture: ARRAY OF INTEGER) =
BEGIN
FOR i := FIRST(culture) TO LAST(culture) DO
IF culture[i] = 1 THEN
IO.PutChar('#');
ELSE
IO.PutChar('_');
END;
END;
END Put;
BEGIN
FOR i := 0 TO 9 DO
IO.Put("Generation " & Fmt.Int(i) & " ");
Put(culture);
IO.Put("\n");
Step(culture);
END;
END Cell.