#range

range_rover

Function to pack integers into ranges

3 releases

0.1.2 Jul 17, 2023
0.1.1 Oct 16, 2022
0.1.0 Oct 16, 2022

#536 in Compression


Used in roomor

MIT license

5KB
67 lines

Function to pack integers into ranges.

Takes a custom sequence of non-repeating integers and produces a sorted vector of ranges.

Example:

use range_rover::range_rover;

let input = vec![-1, -2, 2, 0, 7, 10, -4, 1, 3, 6, -3, 4, 9, 8];
let result = range_rover(input);
assert_eq!(result, vec![-4..=4, 6..=10]);

Dependencies

~465KB