Anonymous user
One-dimensional cellular automata: Difference between revisions
One-dimensional cellular automata (view source)
Revision as of 22:15, 28 November 2020
, 3 years agoUpdated to compile with Nim 1.4. Changed indentation and identifiers to conform to guidelines. Added missing call to procedure.
(Updated to compile with Nim 1.4: replaced "repeatChar" by "repeat" from module "strutils".) |
(Updated to compile with Nim 1.4. Changed indentation and identifiers to conform to guidelines. Added missing call to procedure.) |
||
Line 3,320:
'''Using nested functions and method calling style:'''
<lang Nim>proc cellAutomata =
▲ proc evolve_into(X, T : var string) =
let
▲ for i in X.low..X.high:
alive = x[i] ==
left = if i == x.low:
t[i] =
if alive: (if left
else:
swap t,
</pre>▼
cellAutomata()
{{out}}
<pre>.ooo.oo.o.o.o.o..o..
.o.ooooo.o.o.o......
..oo...oo.o.o.......
..oo...ooo.o........
..oo...o.oo.........
..oo....ooo.........
..oo....o.o.........
..oo.....o..........
..oo................
..oo................</pre>
=={{header|OCaml}}==
|