Skip to main content

contiguous_list

Function contiguous_list 

Source
pub fn contiguous_list<T>(values: &[T]) -> bool
where T: Copy + PartialEq + Add<Output = T> + One,
Expand description

Whether each value is one more than the one before: music21’s contiguousList, which wants them sorted first. An empty list is contiguous here; music21 cannot look at its first value.

use music21::common::numbertools::contiguous_list;

assert!(contiguous_list(&[3, 4, 5, 6]));
assert!(!contiguous_list(&[3, 4, 5, 6, 8]));