cal by notogawa

import System.Time
m@main=getLine>>=mapM(putStrLn.g.take 21).f.map read.words>>m
f[m+1,y]=[h$shows([(January)..]!!m)$' ':show y," Su Mo Tu We Th Fr Sa"]++take 6(iterate(drop 21)$(3*scanl(+)6([0..]>>=d)!!(12*y+m)#7)%([1..d y!!m]>>=s.show))
d n=[a,28+0^(n#4+0^n#25*n#16),a,30,a,30,a,a,30,a,30,a]
a=31
g(_:x)=x
g x=x
h x=div(22-l x)2%x++9%""
s n=(3-l n)%n
a%b=([1..a]>>" ")++b
(#)=mod
l=length

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page