Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Be more consistent about flattening with infix:<xx>
  • Loading branch information
Mouq committed Mar 11, 2015
1 parent 7b153f5 commit a3b5619
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/core/List.pm
Expand Up @@ -659,26 +659,24 @@ sub list(|) {

proto sub infix:<xx>(|) { * }
multi sub infix:<xx>() { fail "No zero-arg meaning for infix:<xx>" }
multi sub infix:<xx>(Mu \x) {x }
multi sub infix:<xx>(Mu \x, $n is copy, :$thunked!) {
$n = nqp::p6bool(nqp::istype($n, Whatever)) ?? Inf !! $n.Int;
multi sub infix:<xx>(Mu \x) { x }
multi sub infix:<xx>(Mu \x, Real() $n is copy, :$thunked!) {
GatherIter.new({ take x.() while --$n >= 0; }, :infinite($n == Inf)).list
}
multi sub infix:<xx>(Mu \x, Whatever, :$thunked!) {
GatherIter.new({ loop { take x.() } }, :infinite(True)).flat
GatherIter.new({ loop { take x.() } }, :infinite(True)).list
}
multi sub infix:<xx>(Mu \x, Whatever) {
GatherIter.new({ loop { take x } }, :infinite(True)).flat
GatherIter.new({ loop { take x } }, :infinite(True)).list
}
multi sub infix:<xx>(Mu \x, $n) {
my int $size = $n.Int;
multi sub infix:<xx>(Mu \x, Int() $n) {
my int $size = $n + 1;

my Mu $rpa := nqp::list();
if $size > 0 {
if $size > 1 {
nqp::setelems($rpa, $size);
nqp::setelems($rpa, 0);

$size = $size + 1;
nqp::push($rpa,x) while $size = $size - 1;
}

Expand Down

0 comments on commit a3b5619

Please sign in to comment.