Skip to content
Permalink
Browse files

Re-imagine PR #2493

To fix at least laziness check on [\+]  Jeremy Studer++ for PR
  • Loading branch information...
lizmat committed Mar 2, 2019
1 parent 3be705f commit 8f424c9d8ecac7c6fbf4f3aa7e0e5fc4b46ea8fe
Showing with 20 additions and 4 deletions.
  1. +20 −4 src/core/List.pm6
@@ -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
)
)
}
}

0 comments on commit 8f424c9

Please sign in to comment.
You can’t perform that action at this time.