Month: October 2013

Calculating distance with Scala’s foldLeft

comment 1
Dev

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-5f2b52f3b9d13879241093/] 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 […]