Month: October 2013

Calculating distance with Scala’s foldLeft

comment 1

I wanted a way to calculate the total distance of a GPS track. A track is basically just a list of lat,long pairs – represented in Scala by the following: [crayon-600770b7a5441582509587/] One way to do this would be to iterate over the sequence, calculating the distance between points (using the haversine formula) and updating the sum in a variable but since this is Scala we can do it in a more functional way. According to […]