One-dimensional cellular automata: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) m (→{{header|11l}}) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 322: | Line 322: | ||
Generation 8 __##________________ |
Generation 8 __##________________ |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
|||
<lang rebol>evolve: function [arr][ |
|||
ary: [0] ++ arr ++ [0] |
|||
ret: new [] |
|||
loop 1..(size ary)-2 'i [ |
|||
a: ary \ i-1 |
|||
b: ary \ i |
|||
c: ary \ i+1 |
|||
if? 2 = a+b+c -> 'ret ++ 1 |
|||
else -> 'ret ++ 0 |
|||
] |
|||
ret |
|||
] |
|||
printIt: function [arr][ |
|||
print replace replace join map arr => [to :string] "0" "_" "1" "#" |
|||
] |
|||
arr: [0 1 1 1 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 0] |
|||
printIt arr |
|||
newGen: evolve arr |
|||
while [newGen <> arr][ |
|||
arr: newGen |
|||
newGen: evolve arr |
|||
printIt newGen |
|||
]</lang> |
|||
{{out}} |
|||
<pre>_###_##_#_#_#_#__#__ |
|||
__##___##_#_#_______ |
|||
__##___###_#________ |
|||
__##___#_##_________ |
|||
__##____###_________ |
|||
__##____#_#_________ |
|||
__##_____#__________ |
|||
__##________________ |
|||
__##________________</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |