Combinations
AUTHOR
Filip Sergot
Prints all the combinations of items from the given array.
What's interesting here?
multi subroutines
shortened use of $_ variable
placeholder variables
Features used
Placeholder variables
- https://doc.perl6.org/language/variables
use v6;
multi combs(@, 0) { "" };
multi combs { combs(@^dict, $^n - 1) X~ @dict };
(.say for combs(<a b c>, $_)) for 1..4;
# vim: expandtab shiftwidth=4 ft=perl6