如何在LISP中列出从1800开始的所有闰年?

如何在LISP中列出从1800开始的所有闰年?,lisp,common-lisp,clisp,Lisp,Common Lisp,Clisp,我有下面的代码,它接受一个参数,并以相反的顺序打印所有闰年列表。我怎样才能让1800作为默认输入,然后运行命令(leap)列出1800-2018年的所有闰年 代码: (反跳跃(q) (如果(

我有下面的代码,它接受一个参数,并以相反的顺序打印所有闰年列表。我怎样才能让1800作为默认输入,然后运行命令(leap)列出1800-2018年的所有闰年

代码:

(反跳跃(q)
(如果(
我无法完全理解您想做什么,但是:

(defun leapyearp (y)
  ;; is Y a leap year, as best we can tell?
  (= (nth-value 3 (decode-universal-time
                   (+ (encode-universal-time 0 0 0 28 2 y)
                      (* 60 60 24))))
     29))

(defun leapyears (&key (start 1800) (end (nth-value 5 (get-decoded-time))))
  ;; all the leap years in a range
  (loop for y from start to end
        if (leapyearp y) collect y))

我不能完全理解你想做什么,但是:

(defun leapyearp (y)
  ;; is Y a leap year, as best we can tell?
  (= (nth-value 3 (decode-universal-time
                   (+ (encode-universal-time 0 0 0 28 2 y)
                      (* 60 60 24))))
     29))

(defun leapyears (&key (start 1800) (end (nth-value 5 (get-decoded-time))))
  ;; all the leap years in a range
  (loop for y from start to end
        if (leapyearp y) collect y))

如果
q
应默认为
1800
,那么
(leap)
将如何产生1800到2018之间的闰年?
2018
从何而来?如果
q
应该默认为
1800
,那么
(leap)
如何产生1800到2018之间的闰年?
2018
来自哪里?