【发布时间】:2015-03-31 08:07:08
【问题描述】:
我需要进行wireworld 移动,我想将一个函数放入另一个函数(“help1”)但我无法让它工作,有多个文件 这就是我所拥有的
module Transitions.For_List_2D (
transition_world -- :: List_2D Cell -> List_2D Cell
) where
import Data.Cell (Cell)
import Data.Cell (Cell (Head, Tail, Conductor, Empty))
import Data.Coordinates
import Data.Coordinates (Distance,X_Coord,Y_Coord,Coord,Element_w_Coord,)
import Data.List_2D
-- Replace this function with something more meaningful:
transition_world :: List_2D Cell -> List_2D Cell
transition_world w = case w of
[] -> []
x:xs -> transition_cell x : transition_world xs
transition_cell :: Element_w_Coord Cell -> Element_w_Coord Cell
transition_cell a = case a of
(Head,(x_coord,y_coord)) -> (Tail, (x_coord,y_coord))
(Tail,(x_coord,y_coord)) -> (Conductor, (x_coord,y_coord))
(Empty,(x_coord,y_coord))-> (Empty, (x_coord, y_coord))
(Conductor,(x_coord,y_coord)) -> (i want to put working function here)
help1 :: Coord -> List_2D Cell -> List_2D Cell
help1 a = case a of
x:xs
(Conductor, (x_e, y_e))-> List_2D.local_elements(element, (x_e, y_e)): help1 xs
local_element 是我要使用的另一个文件上的函数 另外,如果您需要查看任何其他文件,请询问 感谢任何帮助非常感谢
【问题讨论】:
-
我想你可能只是把
case ... of和函数语法弄乱了,我们看不到你所有的定义(例如,我认为Conductor, ..将是Element_w_Coord Cell但你正在尝试使用它(?)代替List_2D Cell,这将失败)-无论如何尝试help (x:xs) (Conductor ...) = ...而不是help1 a = case a of x:xs ...开始 -
无论如何,请向我们提供报告给您的错误并指出显示错误的行
标签: function haskell cellular-automata