View Single Post
Old 07 September 2012, 12:40   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
You can do this by starting at the first value and search forward while the difference is lower than your threshold. If the interval you searched in covers more than one value then you print these and a blank line after. If the next value after the interval is still inside your list then you repeat the whole procedure.

EDIT: assuming you have a list sorted in ascending order:
Code:
' set the threshold and number of items in our list
t = 5
n = 10

list(n) = list(n-1)+t

' search through the whole list
s = 0
while s < n

 ' find the end of the current interval
 e = s
 while list(e+1)-list(e) < t
  e = e+1
 wend

 ' if there were more than 1 item we print them
 if e-s > 0
  for i = s to e
   print list(i)
  next
  print
 end if

' step to the next item and repeat
s = e+1

wend

Last edited by Leffmann; 07 September 2012 at 12:51.
Leffmann is offline  
 
Page generated in 0.04726 seconds with 11 queries