Haskell 我想进行wireworld移动,但它显示了一个错误
我被要求采取行动。因此,我编写了以下代码,(代码中的所有函数都是在其他模块中定义的,因此,不要担心XD,请随时询问我是否希望查看这些“预定义函数”),但当我在终端上运行时,它显示了一个错误,代码如下:Haskell 我想进行wireworld移动,但它显示了一个错误,haskell,parse-error,Haskell,Parse Error,我被要求采取行动。因此,我编写了以下代码,(代码中的所有函数都是在其他模块中定义的,因此,不要担心XD,请随时询问我是否希望查看这些“预定义函数”),但当我在终端上运行时,它显示了一个错误,代码如下: module Transitions.For_List_2D ( transition_world -- :: List_2D Cell -> List_2D Cell ) where import Data.Cell (Cell (Head, Tail, Conductor, Em
module Transitions.For_List_2D (
transition_world -- :: List_2D Cell -> List_2D Cell
) where
import Data.Cell (Cell (Head, Tail, Conductor, Empty))
import Data.Coordinates
import Data.List_2D
transition_world :: List_2D Cell -> List_2D Cell
transition_world world = case world of
(Head,(x,y)):rest-> (Tail,(x,y)): transition_world rest
(Tail,(x,y)):rest -> (Conductor, (x, y)): transition_world rest
(Empty, (x, y)):rest ->(Empty, (x, y)): transition_world rest
(Conductor, (x, y)):rest
| element_occurrence==1 || element_occurrence==2 = (Head, (x, y)): transitio
n_world rest
| otherwise = (Conductor, (x, y)): transition_world rest
[] -> []
但是,当我在终端上以“/”hs文件名“”运行它时,它显示以下错误:
For_List_2D.hs:23:56: parse error on input '='
我完全被这个错误弄糊涂了
提前谢谢你能帮助我的人 这些线
| element_occurrence==1 || element_occurrence==2 = (Head, (x, y)): transition_world rest
| otherwise = (Conductor, (x, y)): transition_world rest
应该是
| element_occurrence==1 || element_occurrence==2 -> (Head, (x, y)): transition_world rest
| otherwise -> (Conductor, (x, y)): transition_world rest
我们在等式(例如函数定义)中使用=
,在case表达式中使用->
。这些行
| element_occurrence==1 || element_occurrence==2 = (Head, (x, y)): transition_world rest
| otherwise = (Conductor, (x, y)): transition_world rest
应该是
| element_occurrence==1 || element_occurrence==2 -> (Head, (x, y)): transition_world rest
| otherwise -> (Conductor, (x, y)): transition_world rest
我们在等式(例如函数定义)中使用=
,在case表达式中使用->