total-difference

| emacs
(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.

You can comment with Disqus or you can e-mail me at sacha@sachachua.com.