Skip to content

Commit

Permalink
Make Int:D (elem) Range:D be independent of size of Range
Browse files Browse the repository at this point in the history
- if the Range is an .is-int
- also fixes GH #1593, because it doesn't vivify the entire (massive) Range
  • Loading branch information
lizmat committed Mar 6, 2018
1 parent 5feb6bb commit de30c16
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/set_elem.pm6
Expand Up @@ -42,14 +42,20 @@ multi sub infix:<(elem)>(Any $a, Map:D $b --> Bool:D) {
)
)
}
multi sub infix:<(elem)>(Int:D $a, Range:D $b --> Bool:D) {
$b.is-int ?? $b.ACCEPTS($a) !! infix:<(elem)>($a,$b.iterator)
}
multi sub infix:<(elem)>(Any $a, Iterable:D $b --> Bool:D) {
infix:<(elem)>($a,$b.iterator)
}
multi sub infix:<(elem)>(Any $a, Iterator:D $b --> Bool:D) {
nqp::if(
(my $iterator := $b.iterator).is-lazy,
$b.is-lazy,
Failure.new(X::Cannot::Lazy.new(:action<(elem)>)),
nqp::stmts(
(my str $needle = $a.WHICH),
nqp::until(
nqp::eqaddr((my $pulled := $iterator.pull-one),IterationEnd),
nqp::eqaddr((my $pulled := $b.pull-one),IterationEnd),
nqp::if(
nqp::iseq_s($needle,$pulled.WHICH),
return True
Expand Down

0 comments on commit de30c16

Please sign in to comment.