Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make combinations() always return a Seq on succcess
Currently, it returns Seq for all cases except ones that return
empty lists, in which case it returns a List.

Fix by returning a Seq for those cases as well.
  • Loading branch information
zoffixznet committed Dec 28, 2016
1 parent b0e61f3 commit db1836a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/List.pm
Expand Up @@ -7,7 +7,8 @@ my sub combinations(Int() $n, Int() $k) {
# k = 0 → can pick just 1 combination (empty list); return ((),)
# n < k → we don't have enough items to pick a combination of k items; return ()
return ((),).Seq if $k == 0;
return () if $n < 1 or $n < $k or $k < 0;
return Seq.new(Rakudo::Internals.EmptyIterator)
if $n < 1 or $n < $k or $k < 0;

X::OutOfRange.new(
:what("First parameter"),
Expand Down

0 comments on commit db1836a

Please sign in to comment.