6086 comments
2357 subscribers
6228 on Twitter
Subscribe! Feed reader E-mail

total-difference

(defun sacha/total-difference (list)
  "Computes the sum of the differences between successive items in LIST."
  (let ((distance 0))
    (while (cdr list)
      (setq distance (+ (abs (- (car list) (car (cdr list)))) distance))
      (setq list (cdr list)))
    distance))

I used this to calculate the total distance travelled by a read/write
head given the list of tracks.

Short URL: http://sachachua.com/blog/p/1913

On This Day...

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging