I'm asked to make a wireworld move. So i have written the following codes,(all of the function in the code is somehow defined in other modules, so, dont worry about that XD, feel free to ask me if u want to have a look at those "predefined funcs") however when i run it on terminal, it shows a error, here is the code:
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
[] -> []
however, when i ran it on terminal by "./'name of the hs file'", it show the following error:
For_List_2D.hs:23:56: parse error on input '='
Im totally confused by this error Thank you in advance for anyone who can help me.
These lines
| element_occurrence==1 || element_occurrence==2 = (Head, (x, y)): transition_world rest
| otherwise = (Conductor, (x, y)): transition_world rest
should be
| element_occurrence==1 || element_occurrence==2 -> (Head, (x, y)): transition_world rest
| otherwise -> (Conductor, (x, y)): transition_world rest
We use =
in equations (e.g. function definitions) and ->
in case expressions.