diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2022-11-07 00:04:44 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2022-11-07 09:35:20 +0200 |
commit | 2d27a4fbe3d9c8386c5477ac67a129ecba2c3ec7 (patch) | |
tree | 85651d29a659421167f9dade1113c3b7a1283f37 | |
parent | 47c813d6aeccc289dca3c34f9b6ea55771573d55 (diff) | |
download | gcd-2d27a4fbe3d9c8386c5477ac67a129ecba2c3ec7.tar.gz |
lisp: require a number
-rw-r--r-- | gcd.lisp | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -9,9 +9,8 @@ a (gcd2 b (mod a b)))) -(defun gcdn (&rest numbers) - (reduce #'gcd2 (rest numbers) - :initial-value (first numbers))) +(defun gcdn (n &rest ns) + (reduce #'gcd2 ns :initial-value n)) (defun program-args () (or @@ -26,6 +25,8 @@ (map 'list (lambda (x) (parse-integer x :junk-allowed t)) (program-args)))) -(write (apply #'gcdn (numbers))) -(fresh-line) +(let ((ns (numbers))) + (when ns + (write (apply #'gcdn ns)) + (fresh-line))) |