Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #622 from grondilu/patch-4
minor improvement in permutations
  • Loading branch information
lizmat committed Dec 8, 2015
2 parents 97ef742 + cee77a3 commit a0eb104
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/native_array.pm
Expand Up @@ -717,7 +717,7 @@ sub permutations(int $n) {
submethod BUILD(:$n) { $!n = $n; self }
#method is-lazy { True }
method pull-one {
if !@!a { return (@!a = ^$!n).List }
return (@!a = ^$!n).List unless @!a;
# Find the largest index k such that a[k] < a[k + 1].
# If no such index exists, the permutation is the last permutation.
my int $k = @!a.end - 1;
Expand Down

0 comments on commit a0eb104

Please sign in to comment.