Boyko,
Yes, I believe that is it. To test more I
constructed the following definitions. I was impressed that
your solution even got right the example (;dd/) 0 5{bds .
dd =: (datediff~,:datediff)"1
]bds =: >:10 2 [EMAIL PROTECTED] 28
(;/'',bds),.(;/bds),<"2@ dd/~bds
(;dd/) 0 5{bds
On Sun, 8 Apr 2007, Boyko Bantchev wrote:
+ On 4/8/07, Brian Schott <[EMAIL PROTECTED]> wrote:
+ > In casual conversation we talk about how far apart
+ > our birthdays are...
+
+ Perhaps this one is worth considering.
+
+ days=: 31 28 31 30 31 30 31 31 30 31 30 31
+ datediff=: 4 : 0
+ 'm d'=. y-x
+ (12|m-d<0), d+(days{~12|2-~{.y)*d<0
+ )
+
+ Examples:
+ a=. 11 5 NB. Nov 5
+ b=. 1 19 NB. Jan 19
+ a datediff b
+ 2 4 NB. 2 months 4 days from a to b
+ b datediff a
+ 9 17 NB. 9 months 17 days from b to a
+ 3 25 datediff 6 25
+ 3 0 NB. 3 months from Mar 25 to the same date in June
+
+ Of course, there still remains the need to deal with leap
+ years properly, but I am too lazy to do that :)
+
+ Regards,
+ Boyko
+
No laziness, imho.
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm