RosettaCodeData/Task/Langtons-ant/Mathematica/langtons-ant.math
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

6 lines
204 B
Text

direction = 1;
data = SparseArray[{{50, 50} -> -1}, {100, 100}, 1];
NestWhile[
{Re@#, Im@#} &@(direction *= (data[[Sequence @@ #]] *= -1) I) + # &,
{50, 50}, 1 <= Min@# <= Max@# <= 100 &];
Image@data