【问题标题】:I want to make a wireworld move, however it shows me a error我想做一个有线世界移动,但它显示了一个错误
【发布时间】:2013-04-04 12:35:55
【问题描述】:

我被要求进行一次有线世界的移动。所以我写了以下代码,(代码中的所有函数都以某种方式在其他模块中定义,所以,不用担心那个 XD,如果你想看看那些“预定义函数”,请随时问我)但是,当我在终端上运行它时,它会显示错误,这是代码:

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 '='

我完全被这个错误弄糊涂了 提前感谢任何可以帮助我的人。

【问题讨论】:

    标签: haskell parse-error


    【解决方案1】:

    这些行

      | 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
    

    我们在方程式(例如函数定义)中使用=,在案例表达式中使用->

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-19
      • 2010-12-20
      • 1970-01-01
      相关资源
      最近更新 更多