Macro malachite_base::lex_tuples
source ยท macro_rules! lex_tuples { ( ($($vis:tt)*), $k: expr, $exhaustive_struct: ident, $exhaustive_struct_from_single: ident, $exhaustive_fn: ident, $exhaustive_fn_from_single: ident, $single_out: tt, $([$i: expr, $t: ident, $it: ident, $xs: ident, $x:ident]),* ) => { ... }; }
Expand description
Defines lexicographic tuple generators.
Malachite provides lex_pairs
and lex_pairs_from_single
, but you can also define
lex_triples
, lex_quadruples
, and so on, and lex_triples_from_single
,
lex_quadruples_from_single
, and so on, in your program using the code below. The documentation
for lex_pairs
and lex_pairs_from_single
describes these other functions as well.
See usage examples here and here.
use malachite_base::iterators::iterator_cache::IteratorCache;
use malachite_base::lex_tuples;
fn clone_helper<T: Clone>(x: &T, _i: usize) -> T {
x.clone()
}
lex_tuples!(
(pub(crate)),
3,
LexTriples,
LexTriplesFromSingle,
lex_triples,
lex_triples_from_single,
(T, T, T),
[0, X, I, xs, x],
[1, Y, J, ys, y],
[2, Z, K, zs, z]
);
lex_tuples!(
(pub(crate)),
4,
LexQuadruples,
LexQuadruplesFromSingle,
lex_quadruples,
lex_quadruples_from_single,
(T, T, T, T),
[0, X, I, xs, x],
[1, Y, J, ys, y],
[2, Z, K, zs, z],
[3, W, L, ws, w]
);
lex_tuples!(
(pub(crate)),
5,
LexQuintuples,
LexQuintuplesFromSingle,
lex_quintuples,
lex_quintuples_from_single,
(T, T, T, T, T),
[0, X, I, xs, x],
[1, Y, J, ys, y],
[2, Z, K, zs, z],
[3, W, L, ws, w],
[4, V, M, vs, v]
);
lex_tuples!(
(pub(crate)),
6,
LexSextuples,
LexSextuplesFromSingle,
lex_sextuples,
lex_sextuples_from_single,
(T, T, T, T, T, T),
[0, X, I, xs, x],
[1, Y, J, ys, y],
[2, Z, K, zs, z],
[3, W, L, ws, w],
[4, V, M, vs, v],
[5, U, N, us, u]
);
lex_tuples!(
(pub(crate)),
7,
LexSeptuples,
LexSeptuplesFromSingle,
lex_septuples,
lex_septuples_from_single,
(T, T, T, T, T, T, T),
[0, X, I, xs, x],
[1, Y, J, ys, y],
[2, Z, K, zs, z],
[3, W, L, ws, w],
[4, V, M, vs, v],
[5, U, N, us, u],
[6, T, O, ts, t]
);
lex_tuples!(
(pub(crate)),
8,
LexOctuples,
LexOctuplesFromSingle,
lex_octuples,
lex_octuples_from_single,
(T, T, T, T, T, T, T, T),
[0, X, I, xs, x],
[1, Y, J, ys, y],
[2, Z, K, zs, z],
[3, W, L, ws, w],
[4, V, M, vs, v],
[5, U, N, us, u],
[6, T, O, ts, t],
[7, S, P, ss, s]
);