aboutsummaryrefslogtreecommitdiff
path: root/examples.lisp
diff options
context:
space:
mode:
authorColin Okay <cbeok@protonmail.com>2020-08-13 10:38:30 -0500
committerColin Okay <cbeok@protonmail.com>2020-08-13 10:38:30 -0500
commite8c0f8e58b0039d8d3ed886654a5452168168436 (patch)
tree5e9034a3b8cee68a4dad8bb3d35e8ae3a3f457b3 /examples.lisp
parent61c06fc10ee2bad8d810d342a707677ede2c5f78 (diff)
removed replaced $and $or with macros; added reader macro for $$
Diffstat (limited to 'examples.lisp')
-rw-r--r--examples.lisp15
1 files changed, 7 insertions, 8 deletions
diff --git a/examples.lisp b/examples.lisp
index 7bd44e2..973ebee 100644
--- a/examples.lisp
+++ b/examples.lisp
@@ -1,15 +1,14 @@
(defpackage #:lt-examples
- (:use #:cl #:lambda-toosl))
+ (:use #:cl #:lambda-tools))
;; 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 #'*
- (loop :for i :upto (length $digits) :collect (1+ (mod i 2)))
- $digits))
- ($$ (zerop (mod (apply #'+ (mapcar #'sum-dig $digits)) 10))))))
+ (>> 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)))))