NB. isleap y tests for n being a leap year isleap =. '2 | +/ 0 = 4 100 400 | y.' : '' NB. zero? mod 4 100 400 NB. add them up NB. mod 2 ie. Leap iff 1 or 3 tests true NB. day1 y returns 1st day of year, 0 for Sunday, 6 for Saturday day1 =. '7 | y. + -/ <. (y. - 1) % 4 100 400' : '' NB. lengths y returns a vector of lengths of months in year y lengths =. '28 + 3 , (isleap y.) , 10 $ 5 $ 3 2' : '' NB. day1s y returns vector of start days of months in year y day1s =. '7 | (day1 y.) + 0, +/\ _1 }. lengths y.' : '' NB. +/\ cummulative sums of days in months NB. start day + NB. dates y returns 12x42 matrix of days in months in year y dates =. '(m<:lengths y.) * (m>0) * m =. (12 42 $ 1 + i. 42) - day1s y.' : '' NB. raw dates shift start NB. in month and +ve NB. suppress0 0 --> ' ' suppress0 1 --> ' 1' etc. suppress0 =. ',/ (('' ''&[) ` (3&":) @. *)"0 y.' : '' NB. 3 digits format if positive (*), else NB. ' ' if zero NB. header1 y adds names of days to formatted dates y header1 =. ' '' Su Mo Tu We Th Fr Sa'' ,"1 suppress0"1 dates y.' : '' NB. day names appnd int->char dates NB. header2 y adds names of months to header1 y header2 =. '(sp ,"1 (12 3 $ ''JanFebMarAprMayJunJulAugSepOctNovDec'')) ,"1 (sp =. 9#'' '') ,"1 header1 y.' : '' NB. calendar y returns 2D char matrix being the calendar for year y calendar =. '(": 4 3 $ <"2 (8 21 & $)"1 header2 y.) ,"2 (35 ": y.)' : '' NB. reshape each month NB. box NB. format 4x3 reshape appnd year NB.---------------------------------------------------------------------------- NB. Lloyd Allison.