One-dimensional cellular automata: Difference between revisions
Content added Content deleted
Line 3,369: | Line 3,369: | ||
=={{header|Oforth}}== |
=={{header|Oforth}}== |
||
<lang Oforth>: nextGen(l) |
<lang Oforth>: nextGen( l ) |
||
| i | |
| i s | |
||
l byteSize dup ->s String newSize |
|||
StringBuffer new |
|||
s loop: i [ |
|||
i 1 if=: [ 0 ] else: [ i 1- l byteAt '#' = ] |
|||
i l byteAt '#' = + |
|||
i s if=: [ 0 ] else: [ i 1+ l byteAt '#' = ] + |
|||
2 = |
2 if=: [ '#' ] else: [ '_' ] over add |
||
] |
] |
||
; |
|||
: gen( l n -- ) |
|||
l dup .cr #[ nextGen dup .cr ] times( n ) drop ;</lang> |
|||
{{out}} |
{{out}} |