diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2022-10-30 23:19:41 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2022-11-01 08:59:25 +0200 |
commit | 47c813d6aeccc289dca3c34f9b6ea55771573d55 (patch) | |
tree | 1d9a64b35609e059dd1d631c02be92641ac73c9a /gcd.lisp | |
parent | f32b5b9b82b5af6c5c74887fe6c8348fd8738ee6 (diff) | |
download | gcd-47c813d6aeccc289dca3c34f9b6ea55771573d55.tar.gz |
Update Lisp
Diffstat (limited to 'gcd.lisp')
-rw-r--r-- | gcd.lisp | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -1,7 +1,8 @@ ; SYNOPSIS: ; # clisp gcd.lisp 11 22 33 121 +; # ecl --shell gcd.lisp 121 22 33 +; # gcl -f gcd.lisp 121 22 33 ; # sbcl --script gcd.lisp 121 22 33 -; (defun gcd2 (a b) (if (= b 0) @@ -12,18 +13,19 @@ (reduce #'gcd2 (rest numbers) :initial-value (first numbers))) -; Command line access is different on different Lisps (defun program-args () (or - #+SBCL (rest *posix-argv*) #+CLISP *args* - ;#+ECL (ext:command-args) - ;#+CMU extensions:*command-line-words* - ;#+LISPWORKS system:*line-arguments-list* + #+ECL (ext:command-args) + #+GCL si::*command-args* + #+SBCL *posix-argv* nil)) -(write (apply #'gcdn - (map 'list #'parse-integer (program-args)) - )) +(defun numbers () + (remove nil + (map 'list (lambda (x) (parse-integer x :junk-allowed t)) + (program-args)))) + +(write (apply #'gcdn (numbers))) (fresh-line) |