Comment detail

除算・余剰を使わずに閏年 (Nested Flatten)
無限リストつかいます。

実行例:
*Main> :main 1900
False
*Main> :main 2000
True
*Main> :main 2008
True
*Main> :main 2100
False

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
module Main (main) where

import System.Environment

main :: IO ()
main = print . (ys !!) . read . head =<< getArgs

y4s = [True,False,False,False]
y100s = False : tail (take 100 $ cycle y4s)
y400s = True : tail (take 400 $ cycle y100s)

ys = cycle y400s

Index

Feed

Other

Link

Pathtraq

loading...