I have homework where I am to update a list using a function that takes two elements and returns a value of part of the first element given in the function. So it's required to update the entire listing by going through each element and update its value by applying the function against all other elements in the list (including itself).
So far I've been trying to firstly map the list (so that each element is done the same) and then specifically update each elements value by mapping again just the value of the specified element however in trying to map just the specific value through: the function, the specific element and the entire list I keep getting complaints that I'm inferring the list of values made from the 'map function p@list list' rather than simply giving the value at p@list. Here is a sample of what I've been trying to implement:
res :: X -> X -> Z -- function given
myf :: [X] -> [X] -- Here is my function
myf ps = map newf ps
where
newf p@(X oldz) = X newz
newz = map (res p) ps
Is this the correct method to try to update a list against the entire list itself?
EDIT: spelling mistakes and grammar- my apologies on not also putting the homework tag on it