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


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

See Also

array-contains-a-value.pl

Determine whether an array contains a value

bottles.pl

99 bottles of beer

malware_analysis.raku

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.