My approach to binning would be simple. You look at the first element of the array @split_entries and the index of the potential candidates, and increase that index until the potential candidate is larger than your distance. All elements between the first element and the index of the potential candidate then belong into one bin.
An example, for a distance of 5:
11 12 16 17 22 30
First you look at the first position in your array (11). The next candidate is at the second position, and its value is 12. abs(12-11) < 5, so you increase the index of your candidate. The next candidate is at the third position, and its value is 16. abs(16-11) >= 5, so your first bin are the first and second entries in the array, 11 and 12.
Now, you start the same thing over, as there are still elements in your array after removing 11 and 12 from it.
You look at the first position in your array (16). The next candidate is at the second position, and its value is 17. abs(16-17) < 5, so you increase the index of your candidate. The next candidate is at the third position, and its value is 22. abs(22-16) >= 5, so your first bin are the first and second entries in the array, 16 and 17.
... and so on.
In reply to Re^3: Stuck with manipulating an array
by Corion
in thread Stuck with manipulating an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |