You may try monad { which forms outer product from its argument. eg
   >,{2004;(1+i.12);1 2
2004  1 1
2004  1 2
2004  2 1
2004  2 2
2004  3 1
2004  3 2
2004  4 1
2004  4 2
2004  5 1
2004  5 2
2004  6 1
2004  6 2
2004  7 1
2004  7 2
2004  8 1
2004  8 2
2004  9 1
2004  9 2
2004 10 1
2004 10 2
2004 11 1
2004 11 2
2004 12 1
2004 12 2

and then elminate invalid days such as 29 feb or 31 jun

Вск, 28 Ноя 2010, PackRat писал(а):
> [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

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to