Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trace2 :: Commands -> Angle -> Colour -> [ColouredLine]
- trace2 commands theta col
- = trace2' commands ((0, 0), 90.0) []
- where
- trace2' :: Commands -> TurtleState -> Stack -> [ColouredLine]
- trace2' "" state tStack
- = []
- trace2' ('[' : cmds) state tStack
- = trace2' cmds state (state : tStack)
- trace2' (']': cmds) state (headStack : tailStack)
- = trace2' cmds headStack tailStack
- trace2' (cmd : cmds) state@(initial, _) tStack
- | cmd == 'F' = (initial, final, col) : trace2' cmds finalState tStack
- | otherwise = trace2' cmds finalState tStack
- where
- finalState@(final, _) = move cmd theta state
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement