mclangc/examples/rule110.mcl

39 lines
607 B
Plaintext
Raw Permalink Normal View History

include "std.mcl"
2023-03-20 11:39:04 +00:00
macro BOARD_SIZE 100 end
mem BOARD_SIZE 2 - + 1 @8
0 while dup BOARD_SIZE 2 - < do
0 while dup BOARD_SIZE < do
dup mem + !8 if
2023-03-20 14:33:08 +00:00
dup mem + BOARD_SIZE + '*' @8
else
2023-03-20 14:33:08 +00:00
dup mem + BOARD_SIZE + ' ' @8
end
1 +
end
2023-03-20 14:33:08 +00:00
mem + BOARD_SIZE + '\n' @8
2023-03-20 11:39:04 +00:00
BOARD_SIZE 1 + mem BOARD_SIZE + puts
// pattern
mem !8 1 shl
mem 1 + !8
bor
2023-03-20 11:39:04 +00:00
1 while dup BOARD_SIZE 2 - < do
swap 1 shl 7 band
over mem + 1 + !8 bor
2dup 110 swap shr 1 band
swap mem + swap @8
swap
1 +
end
drop drop
1 +
end
drop