Application of a multi-input function using a card? (Haskell)
Guys from G'day,
Currently trying to complete a little homework I am working on and the problem is when I try to apply a map to a function that takes multiple inputs.
so in case i use processList f (x: xs) = map accelerateList f xs x xs
processList gets a float (f) and a list, which it sorts into another list
Accelerate List takes a float (f) List and list object through which it returns another list object
I know my fast-track list code is correct, but I can't for life get the syntax for this code:
processList :: Float -> [Object] -> [Object]
accelerate f [] = []
accelerate f [x] = [(accelerateForce f x x)]
accelerate f (x:xs) = map accelerateList f xs x xs
Any ideas? I scratch my head for about 3 hours. I know this is really easy.
a source to share
First, you probably want to use some parentheses here:
map accelerateList f xs x xs
The function map
takes exactly two arguments (not five), so you should do something like this, for example:
map (accelerateList f xs x) xs
But on the other hand it doesn't match your function signatures. The problem is probably that you haven't structured your solution well enough. Maybe a separate question, but an explanation of what you are trying to accomplish with the acceleration function (or which is ever "top") will certainly help.
a source to share