({. + 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

Reply via email to