Combinatory
You are reading the documentation for combinatory version 1.0.0
Allows to combinate values of two dimensional iterators / collections.
For example, the combinations of each value [1, 2]
with the values [a, b]
are:
- (1,a).
- (1,b).
- (2,a).
- (2,b).
The following code shows every combination of a menu-deal composed of a main, a side, and a dessert, having two options for each:
use Combinatory;
const SIDES: & = &;
const MAIN: & = &;
const DESSERTS: & = &;
let possible_menus = new
.ref_combinations
.enumerate
.map
.
.join;
println!;
assert_eq!;
This code will print:
1 - Soup, Chicken, Vanilla ice cream
2 - Bread and butter, Chicken, Vanilla ice cream
3 - Soup, Fillet with fries, Vanilla ice cream
4 - Bread and butter, Fillet with fries, Vanilla ice cream
5 - Soup, Chicken, Souffle
6 - Bread and butter, Chicken, Souffle
7 - Soup, Fillet with fries, Souffle
8 - Bread and butter, Fillet with fries, Souffle