Function malachite_base::iterators::comparison::is_strictly_zigzagging
source · pub fn is_strictly_zigzagging<I: Iterator>(xs: I) -> bool
Expand description
Determines whether the sequence strictly zigzags.
A strictly zigzagging sequence is one where every odd-indexed element is greater than its even-indexed neighbors, or one where every odd-indexed element is less than its even-indexed neighbors.
This function will hang if given an infinite strictly zigzagging iterator.
§Examples
use malachite_base::iterators::comparison::is_strictly_zigzagging;
assert_eq!(is_strictly_zigzagging([1, 2, 3, 4].into_iter()), false);
assert_eq!(is_strictly_zigzagging([4, 3, 2, 1].into_iter()), false);
assert_eq!(is_strictly_zigzagging([1, 3, 2, 4].into_iter()), true);
assert_eq!(is_strictly_zigzagging([1, 2, 2, 4].into_iter()), false);