r =. 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
    r
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
    ([ * +)/\.&.|. 1 , 2 ~:/\ r
1 2 0 1 2 3 4 5 0 1 2 3 4 0 0 1 2 3 4 5 6 7 8 0 0 1 0 0 1 2

Henry Rich

David Vincent-Jones 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
> 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to