# P26 - Generate the combinations of k distinct objects chosen from the n elements of a list.

*Author: Ryan Connelly*

# Example

> say c(2, ); ((a b) (a c) (a d) (a e) (b c) (b d) (b e) (c d) (c e) (d e))

use v6; multi sub c(0, @xs) { return ((),) } multi sub c(Int $n, []) { return () } multi sub c(Int $n, [ $x, *@xs ]) { |map({($x, |@$_)}, c($n - 1, @xs)), |c($n, @xs); } my @combos = c(3, ); say @combos.elems; say @combos[200..*];