One-dimensional cellular automata: Difference between revisions

m
Line 3,031:
 
=={{header|Julia}}==
=== Julia: Implementation as a function accepting a Vector of Bool ===
=== functional ===
<syntaxhighlight lang="julia">
automaton(g::Vector{Bool}) =
for i ∈ 0:9
println(join(alive ? '#' : '_' for alive ∈ g))
Line 3,041:
automaton([c == '#' for c ∈ "_###_##_#_#_#_#__#__"])
</syntaxhighlight>
=== Julia: Implementation as an iterable struct ===
<syntaxhighlight lang="julia">
struct Automaton g₀::Vector{Bool} end
Line 3,051:
println(io, join(alive ? '#' : '_' for alive ∈ g)) end
 
Automaton([c == '#' for c ∈ "_###_##_#_#_#_#__#__"])</syntaxhighlight>
</syntaxhighlight>
{{out}}
<pre>
39

edits