Skip to content

Commit

Permalink
Re-imagine PR #2493
Browse files Browse the repository at this point in the history
To fix at least laziness check on [\+]  Jeremy Studer++ for PR
  • Loading branch information
lizmat committed Mar 2, 2019
1 parent 3be705f commit 8f424c9
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/core/List.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,26 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}

method is-lazy() {
nqp::if(
nqp::isconcrete($!current-iter),
$!current-iter.is-lazy,
False
nqp::unless(
nqp::isconcrete($!current-iter) && $!current-iter.is-lazy,
nqp::if(
nqp::isconcrete($!future),
nqp::stmts( # Check $!future to determine if any element is lazy
(my \iter := nqp::iterator($!future)),
nqp::while(
iter
&& nqp::can((my $cur := nqp::shift(iter)),'is-lazy')
&& nqp::isfalse($cur.is-lazy),
nqp::null
),
nqp::if(
iter,
True, # did not did do all iterations, so lazy
$cur.is-lazy # check last one, could be non-lazy
)
),
False
)
)
}
}
Expand Down

0 comments on commit 8f424c9

Please sign in to comment.