Most years have 52 weeks, some have 53, according to ISO8601.



Task

Write a function which determines if a given year is long (53 weeks) or not, and demonstrate it.




% We can't hide one procedure inside another, but
% we can hide the helper `p' in a cluster
 
longyear = cluster is test
    rep = null
 
    p = proc (n: int) returns (int)
        return ((n + n/4 - n/100 + n/400) // 7)
    end p
 
    test = proc (y: int) returns (bool)
        return (p(y)=4 | p(y-1)=3)
    end test
end longyear
 
start_up = proc ()
    po: stream := stream$primary_output()
 
    for i: int in int$from_to(2000, 2100) do
        if longyear$test(i) then
            stream$putl(po, int$unparse(i))
        end
    end
end start_up