Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. trace2 :: Commands -> Angle -> Colour -> [ColouredLine]
  2. trace2 commands theta col
  3. = trace2' commands ((0, 0), 90.0) []
  4. where
  5. trace2' :: Commands -> TurtleState -> Stack -> [ColouredLine]
  6. trace2' "" state tStack
  7. = []
  8. trace2' ('[' : cmds) state tStack
  9. = trace2' cmds state (state : tStack)
  10. trace2' (']': cmds) state (headStack : tailStack)
  11. = trace2' cmds headStack tailStack
  12. trace2' (cmd : cmds) state@(initial, _) tStack
  13. | cmd == 'F' = (initial, final, col) : trace2' cmds finalState tStack
  14. | otherwise = trace2' cmds finalState tStack
  15. where
  16. finalState@(final, _) = move cmd theta state
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement