Langton's ant: Difference between revisions
m
→{{header|APL}}: Formatting
(→{{header|APL}}: Correct coordinate chirality) |
m (→{{header|APL}}: Formatting) |
||
Line 503:
{{works with|Dyalog APL}}
<syntaxhighlight lang="apl">langton ← {⍺←⍵ ⋄ grid←⍺ ⍵⍴0 ⋄ ant←2÷⍨⍺ ⍵ ⋄ dir←?4 ⋄ grid ant dir}
grid[⊂ant]←1-grid[⊂ant]
⍝ coordinates are matrix
ant+←(4 2⍴¯1 0 0
grid ant
}
⍝ to watch it run, open the variable pic in the monitor before executing this step▼
{} { state ∘← ⍵ ⋄ pic ∘← '.⌺'[1+⊃1⌷⍵] ⋄ _←⎕dl ÷500 ⋄ step ⍵} ⍣≡ langton 100</syntaxhighlight>▼
{{Out}}
|