2015-03-31 49 views
-1

我被要求做一个Wireworld线的举动,我想提出一个功能的其他功能(“help1”)内,但我不能让它工作,有多个文件 这里是我Wireworld线哈斯克尔需要帮助

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是,我想,如果你需要查看的任何他的其他文件使用 也是另一个文件中的函数,只问 感谢任何帮助是极大的赞赏

+0

我想你可能只是得到了'的情况下... of'和函数的语法搞砸了,我们没有看到所有的定义(比如我想'指挥,..'将是一个'Element_w_Coord Cell'但你试图用它来代替将失败的List_2D单元格) - 无论如何,试试'help(x:xs)(Conductor ...)= ...'而不是'help1 a = case X的A:XS ...'上手 – Carsten 2015-03-31 08:17:11

+0

在任何情况下,请给我们报告给你点它显示错误(或多个) – Carsten 2015-03-31 08:18:48

回答

0

help1功能期待两个论点,但你只给它一个。

尝试像

help1 coord world = case world of 

尝试在列表上递归做你的实验室,并停止发布关于堆栈溢出分配的问题,特别是与你的真实姓名。

+0

敬请友好行的错误,也许你应该扩大你的回答了一下 - 现在它不是真的比评论 – Carsten 2015-04-01 05:35:56

+0

我的回答是也许不是最民间多,但说实话,我只是希望这之前停止学生越来越风险失败(或更糟)抄袭。这不是一个可以合理回答的问题,而是学生询问为什么他们的“help1”功能不起作用(在这种情况下,我已经回答了他们的问题),或者他们要求为他们提供解决方案转让,这是有问题的。 – Probie 2015-04-01 06:24:41

+0

我的理解和我的评论并不意味着违法 - 是的,OP最有可能失去了所有的兴趣,因为他几秒钟之内就无法解决他的问题。但“家庭作业”的问题上来很多时候(见http://meta.stackoverflow.com/questions/253792/stack-overflow-and-homework-questions)和我的理解是,家庭作业,问题都OK,我们只应该照顾,并给予比完整的答案更多的提示(第一) - 我们不是老师或在这里的父母,这不是我们的责任,如果他们要去欺骗 - 我们来这里是为了帮助 – Carsten 2015-04-01 07:15:48