a=.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
a,: ;(<@(>:@-{.);.2~ }.((0,=)*.0,~~:)}:) +/\0,(}.~:}:)a
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 2 1 2 3 4 5 5 1 2 3 4 4 4 1 2 3 4 5 6 7 8 8 8 1 1 1 0 0
R.E. Boss
-----Oorspronkelijk bericht-----
Van: [email protected]
[mailto:[email protected]] Namens David Vincent-Jones
Verzonden: maandag 16 maart 2009 19:39
Aan: JSoftware
Onderwerp: [Jprogramming] Interval between Repetitions
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