Let’s assume you have an array of numbers and you want to extract intervals from this array. For example, from such an array: 2,3,4,5,8,9,10,11,12,15,18,19,20 you should be getting (2-5), (8-12), (18-20) as intervals.
More bioinformatic case: Let’s assume you ran samtools pileup format and want to extract intervals from the genomic coordinates that has at least one hit.