Anonymous user
Elementary cellular automaton: Difference between revisions
m
→{{header|Prolog}}
(Added prolog implementation) |
|||
Line 1,542:
=={{header|Prolog}}==
<lang prolog>play :- initial(
play(0, _) :- !.▼
play(N, I) :- ▼
maplist(writ, I), nl,▼
apply_rules(I, Next),▼
succ(N1, N),▼
play(N1, Next).</lang>▼
r(0,0,0,0).
Line 1,561 ⟶ 1,568:
r(O,P,Q,P1), r(P,Q,R,Q1), r(Q,R,S,R1), r(R,S,A,S1).
writ(0) :- write('.').
writ(1) :- write(1).
initial([0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0]).
▲play(0, _) :- !.
▲play(N, I) :-
▲ maplist(writ, I), nl,
▲ apply_rules(I, Next),
▲ succ(N1, N),
▲ play(N1, Next).</lang>
=={{header|Python}}==
|