Is there a way to use Haskell's "map" or something similar with multiple arguments?
i.e. to find the distance between a given point (defined as a tuple) and a list of other points:
map distance (-3,-3) buildings
Clearly, that doesn't work, because it tries to map "distance" to (-3,-3), where distance expects two tuples:
let distance pointA pointB = sqrt ( (frst pointB - frst pointA) * (frst pointB - frst pointA) + (scnd pointB - scnd pointA) * (scnd pointB - scnd pointA) )
distance takes two points as arguments: one is (-3,-3) in this example, and one is selected from the list "buildings".
(-3,-3) is just an example. This will have to be a variable; it can't be hardcoded into the function.
Maybe this will make a little more sense:
buildings = [(3,-2),(2,1),(5,3),(4,3),(4,-1)]
firstDiff pointA pointB = subtract ( fst pointA ) ( fst pointB )
secondDiff pointA pointB = subtract ( snd pointA ) ( snd pointB )
distance pointA pointB = sqrt ( (firstDiff pointA pointB) * (firstDiff pointA pointB) + (secondDiff pointA pointB) * (secondDiff pointA pointB))
--- What I need to happen here is a list "score" to be created by taking all distances from a point in a list lPoints to a point in list buildings.