Langton's ant: Difference between revisions

GP
(added ocaml)
(GP)
Line 390:
Run with:
$ ocaml graphics.cma langton.ml
 
=={{header|PARI/GP}}==
[[File:Langton-pari.png|right|thumb]]
<lang parigp>langton()={
my(M=matrix(100,100),x=50,y=50,d=0);
while(x && y && x<=100 && y<=100,
d=(d+if(M[x,y],1,-1))%4;
M[x,y]=!M[x,y];
if(d%2,x+=d-2,y+=d-1);
);
M
};
show(M)={
my(d=sum(i=1,#M[,1],sum(j=1,#M,M[i,j])),u=vector(d),v=u,t);
for(i=1,#M[,1],for(j=1,#M,if(M[i,j],v[t++]=i;u[t]=j)));
plothraw(u,v)
};
show(langton())</lang>
 
=={{header|PicoLisp}}==