Thanks to Henry and all the others who posted possible solutions!

Henry wrote:
> I don't get what your 'offset' field is 

My use of this verb might have more general applications down the road, 
but my immediate need was for a sort of "month odometer" that could 
start with any month of a year (not just January).  The "offset" was 
the offset from the beginning, so that Jan=1, Feb=2, and so on, making 
9 be the value for starting with September.  I didn't mention months 
because I wanted a general solution to the problem, not a specific one 
that would work only with months.

and Ric wrote:
> I'm not sure what the point of giving a datalist is though since the
> only thing that gets used from it is the number of items in the
> list. 

I used the i.<n> approach in the problem since that's pretty much the 
standard way of signifying data in sample programs.  In hindsight, I 
probably should NOT have used that approach, since that approach could 
actually have made the solution less general since it might work only 
for data in consistent serial order.  Although 

   datalist=. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18...

is ONE set of data which should work with the proposed algorithm, the 
proposed solution(s) should ALSO work with something like this:

   datalist=. 0 3 4 10 14 15 16 17 21 26 27 28...

I know that Henry's solution gives the correct values for this 
datalist, and the others might as well (I didn't test them).

My next step is to handle the turnover of years for each 12 months as a 
formua/algorithm that operates on the whole dataset at once (at the 
same time as this current algorithm).  I prefer trying things myself 
first, but you may see another question to the forum if I'm stumped.

I have yet another question, but since it's a different topic, I'll 
pose it separately.  Thanks again for the solutions!


Harvey

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

Reply via email to