閏年か判定する


閏年か判定する

閏年の条件

 (import (rnrs))
 (define (leap-year? year)
     (or (and (zero? (mod year 4))
              (not (zero? (mod year 100))))
         (zero? (mod year 400))))

↓こう書いたほうが効率が良い。

 (import (rnrs))
 (define (leap-year? year)
   (and (zero? (mod year 4))
     (or (not (zero? (mod year 100)))
       (zero? (mod year 400)))))