【问题标题】:wireworld haskell help needed需要wireworld haskell帮助
【发布时间】: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


【解决方案1】:

您的 help1 函数需要两个参数,但您只给它一个。

试试类似的东西

help1 coord world = case world of

尝试在列表上的递归上进行实验,并停止发布有关堆栈溢出的作业问题,尤其是使用您的真实姓名。

【讨论】:

  • 请保持友好,也许你应该扩大你的答案 - 现在它不仅仅是一个评论
  • 我的回答可能不是最礼貌的,但老实说,我只是希望在学生因抄袭而面临失败(或更糟)的风险之前停止这种情况。这不是一个可以用给出的内容合理回答的问题,学生要么在问为什么他们的“help1”功能不起作用(在这种情况下我已经回答了他们的问题),要么他们在寻求解决他们的问题分配,这是有问题的。
  • 我理解并且我的评论并不是冒犯的意思——是的,OP 很可能已经失去了所有的兴趣,因为他无法在几秒钟内解决他的问题。但是“家庭作业”问题经常出现(见meta.stackoverflow.com/questions/253792/…),我的理解是家庭作业问题是可以的,我们只需要注意并给出比完整答案更多的提示(首先)——我们不是老师或父母在这里,如果他们作弊不是我们的责任 - 我们是来帮忙的
  • 呃,我只是想在函数(帮助 1)中获得一点帮助,我输入了我的名字,所以我的代码是我的,如果有帮助,我也打算这样做引用谁曾经帮助过因为我想避免抄袭对不起,如果我造成任何不便,p.s 我没有回应因为我有一个忙碌的考试周
猜你喜欢
  • 2022-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-26
  • 1970-01-01
  • 1970-01-01
  • 2022-01-04
  • 2017-10-05
相关资源
最近更新 更多