Wireworld: Difference between revisions

Content deleted Content added
Spoon (talk | contribs)
Solved the task for Smalltalk; linked to new page to keep size down.
GP
Line 1,549: Line 1,549:
{Delay 500}
{Delay 500}
end</lang>
end</lang>

=={{header|PARI/GP}}==
<lang parigp>\\ 0 = conductor, 1 = tail, 2 = head, 3 = empty
wireworldStep(M)={
my(sz=matsize(M),t);
matrix(sz[1],sz[2],x,y,
t=M[x,y];
if(t,
[0,1,3][t]
,
t=sum(i=max(x-1,1),min(x+1,sz[1]),
sum(j=max(y-1,1),min(y+1,sz[2]),
M[i,j]==2
)
);
if(t==1|t==2,2,3)
)
)
};
animate(M)={
while(1,display(M=wireworldStep(M)))
};
display(M)={
my(sz=matsize(M),t);
for(i=1,sz[1],
for(j=1,sz[2],
t=M[i,j];
print1([".","t","H"," "][t+1])
);
print
)
};
animate(read("wireworld.gp"))</lang>


=={{header|Perl 6}}==
=={{header|Perl 6}}==