Permalink
Browse files

implement List.combinations(Range $)

  • Loading branch information...
grondilu authored and timo committed Oct 4, 2013
1 parent 1371ccc commit 5e56c98fb18c79bc4d3ba0d22c366ce20a29f424
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/core/List.pm
View
@@ -547,7 +547,10 @@ my class List does Positional { # declared in BOOTSTRAP
gather take self[@$_] for combinations self.elems, $of
}
multi method combinations( Range $of = 0 .. * ) {
- X::NYI.new.throw;
+ gather for @$of {
+ last if $_ > self.elems;
+ take self.combinations($_);
+ }
}
my sub permutations(Int $n) {

0 comments on commit 5e56c98

Please sign in to comment.