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

Source code: combinations.pl


use v6;

multi combs(@, 0) { "" };
multi combs { combs(@^dict, $^n - 1) X~ @dict };

(.say for combs(<a b c>, $_)) for 1..4;