In the case that you want to remove these, I would recommend making the
function (you might already have it) ndays giving the number of days in a
given month. Then the solution is

   months=. >,{ (2004 1) ([+i.@>:@-~)&.> (2006 12)
   ; <@(,"1 0 i...@ndays)"1 months

Marshall

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of R.E. Boss
Sent: Monday, November 29, 2010 12:05 PM
To: 'Programming forum'
Subject: Re: [Jprogramming] Calendrical "odometer"--how to?

Problem remains the invalid days such as 29 feb or 31 jun, not to mention
leap years. 


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming- 
> [email protected]] Namens Devon McCormick
> Verzonden: maandag 29 november 2010 16:28
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Calendrical "odometer"--how to?
> 
> This might also suffice:
>    >: 0 12 12 #: (12*i.36)+0 12 12 #. <:2004 1 1
> 2004  1 1
> 2004  2 1
> 2004  3 1
> 2004  4 1
> 2004  5 1
> 2004  6 1
> 2004  7 1
> 2004  8 1
> 2004  9 1
> 2004 10 1
> 2004 11 1
> 2004 12 1
> 2005  1 1
> ...
> 2006 12 1
> 
> 
> On Mon, Nov 29, 2010 at 3:42 AM, R.E. Boss <[email protected]> wrote:
> 
> > ({. + i.@(-~/))&.(todayno :. todate) 2004 1 1,:2006 12 12
> >
> > solves your problems.
> >
> >
> > R.E. Boss
> >
> >
> > > -----Oorspronkelijk bericht-----
> > > Van: [email protected] [mailto:programming- 
> > > [email protected]] Namens PackRat
> > > Verzonden: maandag 29 november 2010 3:50
> > > Aan: Programming forum
> > > Onderwerp: [Jprogramming] Calendrical "odometer"--how to?
> > >
> > > [1] The "London Gold Fix" plot demo I mentioned previously has the
> > > line:
> > >
> > >    bgn=. todayno 2004,.(1+i.12),.1
> > >
> > > I'd like to change the  2004  to something like  (2004+i.3) so 
> > > that
> a
> > > plot could handle multiple years rather than just one.  Although
> that's
> > > the intuitive approach a beginner like me would take, it doesn't
> work
> > > that way.  (The problem, of course, is that "stitch" can take a
> list
> > > and an atom, but it can't take two lists where each value of the
> one
> > > list is repeated as a fill for each value of the other list.)  How
> can
> > > I adjust that line to get an output like this:
> > >
> > > 2004  1  1
> > > 2004  2  1
> > > 2004  3  1
> > > . . .
> > > 2004 12  1
> > > 2005  1  1
> > > 2005  2  1
> > > 2005  3  1
> > > . . .
> > > 2005 12  1
> > > 2006  1  1
> > > 2006  2  1
> > > 2006  3  1
> > > . . .
> > > 2006 12  1
> > >
> > > [2] Additionally, just as a matter of interest, how would one 
> > > write
> a
> > > more complete "calendrical odometer"?  In other words, all three 
> > > elements (year, month, day) cycle through their values.  (Leap
> years
> > > present problems, though.)  The result would look like:
> > >
> > > 2004  1  1
> > > 2004  1  2
> > > . . .
> > > 2004  1 31
> > > 2004  2  1
> > > 2004  2  2
> > > . . .
> > > 2004 12 31
> > > 2005  1  1
> > > 2005  1  2
> > > . . .
> > > 2006 12 31
> > >
> > > (I suppose one could "cheat" by doing the calculation backwards--
> that
> > > is, going from a sequence of day numbers to the equivalent yyyy mm
> dd
> > > values.)
> > >
> > > [3] More challenging (I presume), how would one create such an
> odometer
> > > using any starting and ending dates in the format yyyy mm dd?  I 
> > > presume this might possibly be a multiline explicit verb (no 
> > > tacit, please).  (Again, I suppose one could "cheat", as above.)
> > >
> > > I really do appreciate the help you all give--thanks!
> > >
> > > Harvey
> > >
> > > ------------------------------------------------------------------
> > > -
> ---
> > > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
> > --------------------------------------------------------------------
> > -
> -
> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
> 
> 
> 
> --
> Devon McCormick, CFA
> ^me^ at acm.
> org is my
> preferred e-mail
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

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

Reply via email to