I looked at what I sent for day number, clearly there was one verb missing on the last line.

Here are two versions, a corrected day and day2. day2 is only monadic, and becaues of the changes is faster.

day=: 3 : 0 0 day y
:
if. x do.  y=.0 100 100#: y end.
g=.365&* + -/@:(<.@:%&4 100 400)
m=.31 59 90 120 151 181 212 243 273 304 334
(g <:{.y)+({:y)+(1{y){0 0,m+0,10#-/0=4 100 400|{.y
)

day2=: 3 : 0 if. 1=#y do. y=.0 100 100#: y end.
g=.(365&* + -/@:(<.@:%&4 100 400))<:{.y
m=.0 0 31, 59 90 120 151 181 212 243 273 304 334+0-/ .= 4 100 400|{.y
g +({:y)+(1{y){m
)

Here some timings
ts'todayno 2891 12 5'
.00021  6464
ts'day 2891 12 5'
.00013  6848
ts'day2 2891 12 5'
.00010  3648

Note that day 1 1 1 is 1, not 0


Ralph Selfridge

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to