Macro malachite_base::lex_custom_tuples
source ยท macro_rules! lex_custom_tuples { ( ($($vis:tt)*), $exhaustive_struct: ident, $out_t: ty, $nones: expr, $unwrap_tuple: ident, $exhaustive_fn: ident, $([$t: ident, $it: ident, $xs: ident, $([$i: tt, $x: ident]),*]),* ) => { ... }; }
Expand description
Defines custom lexicographic tuple generators.
You can define custom tuple generators like lex_triples_xxy
in your program using the code
below.
See usage examples here.
use malachite_base::iterators::iterator_cache::IteratorCache;
use malachite_base::lex_custom_tuples;
fn unwrap_triple<X, Y, Z>((a, b, c): (Option<X>, Option<Y>, Option<Z>)) -> (X, Y, Z) {
(a.unwrap(), b.unwrap(), c.unwrap())
}
lex_custom_tuples! {
(pub),
LexTriplesXXY,
(X, X, Y),
(None, None, None),
unwrap_triple,
lex_triples_xxy,
[X, I, xs, [0, x_0], [1, x_1]],
[Y, J, ys, [2, y_2]]
}
lex_custom_tuples!(
(pub),
LexTriplesXYX,
(X, Y, X),
(None, None, None),
unwrap_triple,
lex_triples_xyx,
[X, I, xs, [0, x_0], [2, x_2]],
[Y, J, ys, [1, y_1]]
);
lex_custom_tuples!(
(pub),
LexTriplesXYY,
(X, Y, Y),
(None, None, None),
unwrap_triple,
lex_triples_xyy,
[X, I, xs, [0, x_0]],
[Y, J, ys, [1, y_1], [2, y_2]]
);