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