Created
April 2, 2013 14:18
-
-
Save fabioyamate/5292552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (def check-sum | |
| (fn [sequence] | |
| (apply + (map (fn [position digit] | |
| (* digit (if (odd? position) 1 3))) | |
| (range 1 (inc (count sequence))) | |
| sequence)))) | |
| (defn check-sum-upc [coll] | |
| (apply + (map * | |
| (take (count coll) (cycle '(1 3))) | |
| coll))) | |
| (defn check-sum-upc [coll] | |
| (apply + (map * (cycle '(1 3)) coll))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment