trace :: String -> Float -> Colour -> [ColouredLine]
trace (c:cs) angle colour
= trace' (c:cs) angle colour (0.0,0.0)
where
trace' "" angle colour intvertex = []
trace' (c:cs) angle colour intvertex
| c == 'R' = trace' cs (angle-90) colour intvertex
| c == 'L' = trace' cs (angle+90) colour intvertex
| c == 'F' = [(intvertex,aftvertex,colour)] ++ trace' cs angle colour aftvertex
where
aftvertex = fst (move 'F' (intvertex,angle) angle)
报告:
跟踪“F[RF][LF][FF]”45.0 (1.0,0.0,0.0) = 例外:LSystems.hs:(95,4)-(101,61):函数跟踪中的非详尽模式'
预期测试用例:
[((-8.742278e-8,2.0),(-1.3113416e-7,3.0),(1.0,0.0,0.0)),((-4.371139e-8,1.0),(-0.7071068,1.7071068),( 1.0,0.0,0.0)),((-4.371139e-8,1.0),(-8.742278e-8,2.0),(1.0,0.0,0.0)),((-4.371139e-8,1.0),( 0.7071067,1.7071068),(1.0,0.0,0.0)),((0.0,0.0),(-4.371139e-8,1.0),(1.0,0.0,0.0))]