Skip to content

Instantly share code, notes, and snippets.

@alindeman
Created October 6, 2012 14:53
Show Gist options
  • Save alindeman/3845119 to your computer and use it in GitHub Desktop.
Save alindeman/3845119 to your computer and use it in GitHub Desktop.
; me
(defn check-sum [sequence]
(reduce + (map * (cycle [1 3]) sequence)))
; fp-oo
(def check-sum
(fn [sequence]
(apply + (map (fn [position digit]
(* digit (if (odd? position) 1 3)))
(range 1 (inc (count sequence)))
sequence))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment