Elementary cellular automaton: Difference between revisions

no edit summary
m (→‎{{header|Perl 6}}: Include referenced class to make runnable file)
No edit summary
Line 1,182:
* * * * * * * *
* * * * * * * * * * * * * * * *</lang>
 
=={{header|MontiLang}}==
<lang MontiLang>30 VAR length .
35 VAR height .
FOR length 0 ENDFOR 1 0 ARR VAR list .
length 1 - VAR topLen .
FOR topLen 0 ENDFOR 1 ARR VAR topLst .
 
DEF getNeighbors
1 - VAR tempIndex .
GET tempIndex SWAP
tempIndex 1 + VAR tempIndex .
GET tempIndex SWAP
tempIndex 1 + VAR tempIndex .
GET tempIndex SWAP .
FOR 3 TOSTR ROT ENDFOR
FOR 2 SWAP + ENDFOR
ENDDEF
 
DEF printArr
LEN 1 - VAR stLen .
0 VAR j .
FOR stLen
GET j
TOSTR OUT .
j 1 + VAR j .
ENDFOR
|| PRINT .
ENDDEF
 
FOR height
FOR length 0 ENDFOR ARR VAR next .
1 VAR i .
FOR length
list i getNeighbors VAR last .
i 1 - VAR ind .
last |111| ==
IF : .
next 0 INSERT ind
ENDIF
 
last |110| ==
IF : .
next 1 INSERT ind
ENDIF
 
last |101| ==
IF : .
next 1 INSERT ind
ENDIF
 
last |100| ==
IF : .
next 0 INSERT ind
ENDIF
 
last |011| ==
IF : .
next 1 INSERT ind
ENDIF
 
last |010| ==
IF : .
next 1 INSERT ind
ENDIF
 
last |001| ==
IF : .
next 1 INSERT ind
ENDIF
 
last |000| ==
IF : .
next 0 INSERT ind
ENDIF
clear
i 1 + VAR i .
ENDFOR
next printArr .
next 0 ADD APPEND . VAR list .
ENDFOR</lang>
{{out}}
<lang MontiLang>00000000000000000000000000001
00000000000000000000000000011
00000000000000000000000000110
00000000000000000000000001111
00000000000000000000000011000
00000000000000000000000111001
00000000000000000000001101011
00000000000000000000011111110
00000000000000000000110000011
00000000000000000001110000110
00000000000000000011010001111
00000000000000000111110011000
00000000000000001100010111001
00000000000000011100111101011
00000000000000110101100111110
00000000000001111111101100011
00000000000011000000111100110
00000000000111000001100101111
00000000001101000011101111000
00000000011111000110111001001
00000000110001001111101011011
00000001110011011000111111110
00000011010111111001100000011
00000111111100001011100000110
00001100000100011110100001111
00011100001100110011100011000
00110100011101110110100111001
01111100110111011111101101011
11000101111101110000111111110
11001111000111010001100000011
11011001001101110011100000110
11111011011111010110100001111
10001111110001111111100011000
10011000010011000000100111001
10111000110111000001101101011</lang>
 
=={{header|Perl}}==