diff options
-rw-r--r-- | examples.lisp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/examples.lisp b/examples.lisp index 973ebee..cba556a 100644 --- a/examples.lisp +++ b/examples.lisp @@ -5,10 +5,11 @@ ;; http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers (defun luhn (n) - (flet ((sum-dig (x) (if (> x 9) (- x 9) x))) - (>> n #'reverse - #$(map 'list #'digit-char-p $char) - #$(mapcar #'* + (>> n #'reverse + #$(map 'list #'digit-char-p $char) + #$(mapcar #'* (loop :for i :upto (length $digits) :collect (1+ (mod i 2))) $digits) - #$(zerop (mod (apply #'+ (mapcar #'sum-dig $digits)) 10))))) + #$(mapcar #$$(if (> $$x 9) (- $$x 9) $$x) $digits) + #$(zerop (mod (apply #'+ $digits) 10)))) + |