Function malachite_base::tuples::exhaustive::lex_pairs
source · pub const fn lex_pairs<X: Clone, I: Iterator<Item = X>, Y: Clone, J: Iterator<Item = Y>>(
xs: I,
ys: J
) -> LexPairs<X, I, Y, J> ⓘ
Expand description
This documentation applies not only to lex_pairs
, but also to lex_triples
,
lex_quadruples
, and so on. See lex_tuples
for more information.
Generates all $n$-tuples with elements from $n$ iterators, in lexicographic order.
The order is lexicographic with respect to the order of the element iterators.
All of ys
, zs
, … (but not necessarily xs
) must be finite. If xs
is finite, the
output length is the product of the lengths of all the input iterators. If xs
is
infinite, the output is also infinite.
If any of xs
, ys
, zs
, … is empty, the output is also empty.
Examples
See here.
Examples found in repository?
src/num/conversion/string/options/exhaustive.rs (lines 94-104)
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
pub fn exhaustive_to_sci_options() -> ExhaustiveToSciOptions {
ExhaustiveToSciOptions(Box::new(lex_pairs(
exhaustive_triples(
primitive_int_increasing_inclusive_range(2, 36),
exhaustive_sci_size_options(),
exhaustive_negative_signeds(),
),
lex_pairs(
exhaustive_rounding_modes(),
lex_quadruples_from_single(exhaustive_bools()),
),
)))
}
/// Generates all [`FromSciStringOptions`](super::FromSciStringOptions)s.
///
/// This struct is created by [`exhaustive_from_sci_string_options`]; see its documentation for
/// more.
pub struct ExhaustiveFromSciStringOptions(Box<dyn Iterator<Item = (u8, RoundingMode)>>);
impl Iterator for ExhaustiveFromSciStringOptions {
type Item = FromSciStringOptions;
fn next(&mut self) -> Option<FromSciStringOptions> {
let (base, rounding_mode) = self.0.next()?;
Some(FromSciStringOptions {
base,
rounding_mode,
})
}
}
/// Generates all [`FromSciStringOptions`](super::FromSciStringOptions)s.
///
/// The output length is 210.
///
/// # Complexity per iteration
/// Constant time and additional memory.
pub fn exhaustive_from_sci_string_options() -> ExhaustiveFromSciStringOptions {
ExhaustiveFromSciStringOptions(Box::new(lex_pairs(
primitive_int_increasing_inclusive_range(2, 36),
exhaustive_rounding_modes(),
)))
}