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.




[0q]s0
[1q]s1
[1r- r 1r- * 1r-]sO                             # O = logical OR
##.............................................................................
#     C: for( initcode ; condcode ; incrcode ) {body}
# .[q]           [1]        [2]        [3]       [4]
# #           [initcode] [condcode] [incrcode] [body] (for)
[ [q]S. 4:.3:.2:.x [2;.x 0=. 4;.x 3;.x 0;.x]d0:.x
    Os.L.o
]sF                                             # F = for
##.............................................................................
#                           [1]         [0]
# (.)       [cond_code] [then_code] [else_code] (if_CTE)
[ []S. 0:. 1:. x [0=0 1]x ;. s.L. x]sI          # I = if
##-----------------------------------------------------------------------------
[S. l. l.4/+ l.100/- l.400/+ 7% s.L.]sp         # p
##.............................................................................
[S. [l.    lpx 4=1 0]x
    [l. 1- lpx 3=1 0]x lOx
    s.L.
]si                                             # i = is_long_year
##.............................................................................
[
    # f = from
    # t = to
    # y = year
    # c = count
    st sf                       # fetch args from stack
    [lfsy 0sc]
        [ly lt <0 1]            # cond
        [ly 1+ sy]              # incr y
    [
        [ly lix]                # is_long_year(y)
        [
            [lc 0 <1 0]         # 0<c
            [
                [ lc 10% 0=1 0]         # (c % 10) == 0
                [ AP ]
                [ [ ]P ]
                lIx             # if
            ]
            []
            lIx         # if
            ly n
            lc 1+ sc
        ]
        []
        lIx             # if
    ] lFx       # for
]sD                     # D = doit = print_long_years
##.............................................................................
 
[Long years between 1800 and 2100:]P AP
1800 2100 lDx
AP