Reputation: 33
I have 2 Functions
accelerate :: Float -> [Particle] -> [Particle]
accelerateParticle :: Float -> Particle -> [Particle] -> Particle
and what I am trying to achieve is for every element in [Particle]
apply the accelerateParticle
function. The trouble I have run into is that the accelerateParticle
function relies on using the original [particle]
that is given initally by accelerate. I was thinking of using map like this
map (\particle -> accelerateParticle Float particle [Particle]) [Particle]
but I'm not very sure if this the correct format.
Upvotes: 3
Views: 99
Reputation: 116174
You might be looking for this:
accelerate :: Float -> [Particle] -> [Particle]
accelerate x ps = map (\p -> accelerateParticle x p ps) ps
Note that the list of all particles ps
is used both to map
over it, and as a parameter of accelerateParticle
.
Upvotes: 6