David - something like this?
rs=. 0 2 2 1 2 0 2 1 1 2 0 2 1 1 1 2 1 0 1 0 2 1 0 0 0 2 2 2 0 1 2=/\rs NB. consecutive ones denote repeats 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 >:(3 : '(I. 0 1 E. y)-_1,}:>:I. 1 0 E. y') 2=/\rs NB. Start of one - end of previous 2 5 4 8 1 Regards, Devon On Mon, Mar 16, 2009 at 2:38 PM, David Vincent-Jones <[email protected]>wrote: > I am looking to find the interval between repeating elements: > > Sample series: > 0 2 2 1 2 0 2 1 1 2 0 2 1 1 1 2 1 0 1 0 2 1 0 0 0 2 2 2 0 1 ... > Results: > 1 2 1 2 3 4 5 1 2 3 4 1 2 3 4 5 6 7 8 1 1 2 ..... > > In the above I would have found a 2, 5, 4, 8 and a 1 > I will tabulate the intervals over a very long series. > > The repetitions may be of any length of 0s,1s and 2s > > I am currently looking at some nasty brute force methods but would like > to find some degree of elegance. > > David > > ---------------------------------------------------------------------- > 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
