Langton's ant: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 1,661: | Line 1,661: | ||
[[File:Langtons Ant Locomotive BASIC.png]] |
[[File:Langtons Ant Locomotive BASIC.png]] |
||
=={{header|Mathematica}}== |
|||
[[File:LangtonsAnt.png|right|thumb|Output]] |
|||
<lang mathematica>position = {50, 50}; |
|||
direction = 1; |
|||
data = SparseArray[{position -> -1}, {100, 100}, 1]; |
|||
While[1 <= Min@position <= Max@position <= 100, |
|||
direction *= (data[[Sequence @@ position]] *= -1) I; |
|||
position += {Re@#, Im@#} &@direction]; |
|||
Image[data]</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |