I wonder (remembering that Perl 6 has everything you could wish), whether there are some built-in instruments that can help to produce all the non-empty subsets (order doesn't matter) of a list.
E.g., I have a list:
my @a = 1, 2, 3;
I need a function f
so that f(@a)
will produce:
((1), (2), (3), (1, 2), (1, 3), (2, 3), (1, 2, 3))
@a.combinations(1..*)
will return the Seq
you're looking for. Note that without the argument, an empty list would be generated as first element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With