-1

i am required to make a wireworld move and i want to put a function inside another function("help1") but i can't get it to work, there are multiple files here is what i have

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 

the local_element is a function on another file which i want to use also if you require to view the any of he other files, just ask thanks any help is greatly appreciated

Dan D.
  • 73,243
  • 15
  • 104
  • 123
  • I think you probably just got the `case ... of` and function syntax messed up, and we do not see all your definitions (for example I think `Conductor, ..` will be a `Element_w_Coord Cell` but you are trying to use it (?) in place of a `List_2D Cell` which will fail) - anyway try `help (x:xs) (Conductor ...) = ...` instead of the `help1 a = case a of x:xs ...` to get started – Random Dev Mar 31 '15 at 08:17
  • In any case please give us the errors that are reported to you and point to the line where it is showing the error(s) – Random Dev Mar 31 '15 at 08:18

1 Answers1

1

Your help1 function expects two arguments, but you only give it one.

try something like

help1 coord world = case world of

Try doing your lab on recursion over lists, and stop posting assignment questions on stack overflow, especially with your real name.

Probie
  • 1,371
  • 7
  • 15
  • 1
    please stay friendly and maybe you should expand your answer a bit - right now it's not really more than a comment – Random Dev Apr 01 '15 at 05:35
  • 1
    My response was perhaps not the most civil, but to be honest I just want this to stop before the student risks getting failed (or worse) for plagiarism. It's not a question that can reasonably be answered with what's given, and either the student is asking why their "help1" function doesn't work (in which case I've answered their question) or they're asking for a solution to their assignment, which is problematic. – Probie Apr 01 '15 at 06:24
  • I understand and my comment was not meant as a offense - and yes the OP most likely has lost all interest because he could not get his problem solved in a few seconds. But the "homework" problems come up very often (see http://meta.stackoverflow.com/questions/253792/stack-overflow-and-homework-questions) and what I understand is that homework-questions are ok, we only should take care and give more hints than complete answers (first) - we are not teachers or parents here, it's not our responsibility if they gonna cheat - we are here to help – Random Dev Apr 01 '15 at 07:15
  • uh i was only trying to get a little help with functions in function(help 1) and i put my name so my code is known to be mine and could not be taken also if helpful i planned to cite who ever helped coz i wanna avoid plagerism sorry if i caused any inconvience, p.s i didn't respond coz i've had a busy test week – Johno flores Apr 01 '15 at 10:48