Add tags

Add tags to the following comment

割り切れる数字の部分だけ真で他は偽の値を持つ循環リストを作成し、 周期4、100、400を重ね合せて判定してみました。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
(defun leap-year-p (y)
  (do ((i y (1- i))
       (c4 (%clist 4) (cdr c4))
       (c100 (%clist 100) (cdr c100))
       (c400 (%clist 400) (cdr c400)))
      ((zerop i) (or (and (car c100) (car c400))
                     (and (not (car c100)) (car c4))))))

(defun %clist (freq)
  (let ((l (make-list freq)))
    (setf (car l) t)
    (rplacd (last l) l)
    l))

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...