Updating List Elements, Haskell -


I have homework where I take two elements to update a list using a function and before Assuming the part gives the element in the function so it is necessary to update the entire list by applying the task against all other elements (including self) by going through each element and updating its value.

So far the first thing I am trying to map is to list (so that each element should be the same) and then specifically update the value of the specified element by mapping each element value, though Trying to map only through specific values: Functions, specific elements and complete list I am receiving complaints that instead of giving value to the P @ list, instead of 'map function page list list' Made'm violating values ​​list. Here's a sample of what I'm trying to do:

  res :: X - & gt; X - & gt; Z - Function given myf :: [X] - & gt; [X] - This is my work myf ps = map newf ps where newf p @ (x oldz) = x newz newz = map (res p) ps  

is this the right way < / P>

Edit: Spelling mistakes and grammar- I apologize if I do not even do homework tags on it

Is this the correct way to update a list against the entire list?

I'm not sure the code is right for any action. It seems that you believe that p @ (X oldz) is taking the element from the list with the constructor X oldz and its name is p . But ...

You have to describe how to behave when your list changes after the implementation of map (res p) . If all your "changes" in the list should be made only on the basis of the initial values ​​of the list and from the first element to the last:

  myf ps = (buildPlan ps) ps where buildPlan [] = ID BuildPlan (x: xs) = Map (res x). Some people may like:  
  myf ps = changesPlan ps where change x = map (res x) changesPlan = foldr (.) Id (map)  
If there should be a change from the previous map (res x) in your "Changes" list (you should change the list in non-Fan language while changing)

All elements that will be taken on the next recurrence):

  myf ps0 = rebuildFrom 0 ps0 from where to rebuild from n ps | N & gt; = Length ps = ps from reBild to NS ps = rebild frame (N + 1) ps' where x = ps !! N ps' = map (res x) ps  

Comments