Task

Determine whether a given year is a leap year in the Gregorian calendar.



See also

 Leap year (wiki)


is_leap_year = proc (year: int) returns (bool)
    return(year//400 =0 cor (year//4 = 0 cand year//100 ~= 0))
end is_leap_year
 
start_up = proc ()
    po: stream := stream$primary_output()
    years: sequence[int] := sequence[int]$
        [1899, 1900, 1901, 1902, 1903, 1904, 1905, 1999,
         2000, 2001, 2002, 2003, 2004, 2021, 2022]
 
    for year: int in sequence[int]$elements(years) do
        stream$puts(po, int$unparse(year) || " is ")
        if ~is_leap_year(year) then stream$puts(po, "not ") end
        stream$putl(po, "a leap year.")
    end
end start_up