aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <cbeok@protonmail.com>2020-08-13 12:59:09 -0500
committerColin Okay <cbeok@protonmail.com>2020-08-13 12:59:09 -0500
commit7c6a9b5f456235662f95b2f2d0e75058e94af1c6 (patch)
tree0322bd7ffd3c6ceaa85ccd6583655ac297dfd20a
parent5ea4ca47fee1f39f1fc360d44920c79d94007693 (diff)
updated example
-rw-r--r--examples.lisp11
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))))
+