Comment detail

除算・余剰を使わずに閏年 (Nested Flatten)

This comment is reply for 5339 sumim: 考えたら、べつに無限にせずともこれで十分...(除算・余剰を使わずに閏年). Go to thread root.

まあ、こういうのもあるということで。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
| 閏年か? |

閏年か? := [:int |
    (int isDivisibleBy: 4)
        and: [(int isDivisibleBy: 100) not or: [int isDivisibleBy: 400]]].

閏年か? value: 1900.   "=> false "
閏年か? value: 2000.   "=> true "
閏年か? value: 2008.   "=> true "
閏年か? value: 2100.   "=> false "

Index

Feed

Other

Link

Pathtraq

loading...