Created
October 9, 2014 23:26
-
-
Save jplaza/a739a999b2316a912afb to your computer and use it in GitHub Desktop.
Código de control
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
;; Implementación de Código de control con módulo 11 | |
;; http://es.wikipedia.org/wiki/C%C3%B3digo_de_control | |
(defn verificador-suma-parcial [grupo] (reduce + 0 (map * grupo (range 2 8)))) | |
(defn digito-verificador [clave-acceso] | |
(let [c (partition 6 6 nil (map #(Integer/parseInt (str %)) (reverse clave-acceso))) | |
digito (reduce + 0 (map verificador-suma-parcial c)) | |
m (mod digito 11)] | |
(if (> m 1) (- 11 m) m))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment