From 7c6a9b5f456235662f95b2f2d0e75058e94af1c6 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 13 Aug 2020 12:59:09 -0500 Subject: updated example --- examples.lisp | 11 ++++++----- 1 file 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)))) + -- cgit v1.2.3