Langton's ant: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: some typos) |
m (→{{header|Haskell}}: Fixed types) |
||
Line 2,929: | Line 2,929: | ||
<lang Haskell>data State = State { antPosition :: Point |
<lang Haskell>data State = State { antPosition :: Point |
||
, antDirection :: Point |
, antDirection :: Point |
||
, getCells :: Set Point } |
, getCells :: Set Point } |
||
type Point = (Float, Float)</lang> |
|||
Now we are ready to express the main part of the algorithm |
Now we are ready to express the main part of the algorithm |
||
Line 2,949: | Line 2,951: | ||
task = iterate step |
task = iterate step |
||
>>> dropWhile ((< 50) . distance . antPosition) |
>>> dropWhile ((< 50) . distance . antPosition) |
||
>>> |
>>> getCells . head |
||
where distance (x,y) = max (abs x) (abs y)</lang> |
where distance (x,y) = max (abs x) (abs y)</lang> |
||