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
