Jump to content

One-dimensional cellular automata: Difference between revisions

Line 3,369:
=={{header|Oforth}}==
 
<lang Oforth>: nextGen( l )
| i s |
l byteSize dup ->s String newSize
StringBuffer new
l sizes loop: i [
li at(1 if=: [ 0 ] else: [ i 1- )l byteAt '#' == ]
l at( i 1+l )byteAt '#' == +
li at(s iif=: )[ 0 ] else: [ i 1+ l byteAt '#' == ] +
2 if== ifTrue: [ '#' ] else: [ '_' ] over add
] ;
;
: gen( l n -- )
: gen(l, n) l dup println.cr #[ nextGen dup println.cr ] times( n ) drop ;</lang>
 
{{out}}
1,015

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.