Picking an order for parameters based on partial functions
When we look at complex functions, we'll sometimes see a pattern to the ways we use the function. We might, for example, evaluate a function many times with some argument values that are fixed by context, and other argument values that are changing with the details of the processing.
It can simplify our programming if our design reflects this concern. We'd like to provide a way to make the common parameters slightly easier to work with than the uncommon parameters. We'd also like to avoid having to repeat the parameters that are part of a larger context.
Getting ready
We'll look at a version of the haversine formula. This computes distances between points on the surface of the Earth, using the latitude and longitude coordinates of that point:
c = 2arc sin(√a)
The essential calculation yields the central angle, c, between two points. The angle is measured in radians. We convert it into distance by multiplying by the Earth's mean radius...