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