Skip to content
Permalink
Browse files

Make Seq smartmatch Iterables ok

Solves R#2233
  • Loading branch information...
lizmat committed Aug 29, 2018
1 parent d08a414 commit d3cac14ecea9f5e5e67bace2c0b6d8bb288114e3
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/core/Seq.pm6
@@ -162,6 +162,28 @@ my class Seq is Cool does Iterable does Sequence {
multi method from-loop(&body, &cond, &afterwards) {
Seq.new(Rakudo::Iterator.CStyleLoop(&body, &cond, &afterwards))
}

multi method ACCEPTS(Seq:D: Iterable:D \iterable --> Bool:D) {
nqp::if(
(my \liter := self.iterator).is-lazy,
False,
nqp::if(
(my \riter := iterable.iterator).is-lazy,
False,
nqp::stmts(
nqp::until(
nqp::eqaddr((my \left := liter.pull-one),IterationEnd),
nqp::if(
nqp::eqaddr((my \right := riter.pull-one),IterationEnd)
|| nqp::not_i(right.ACCEPTS(left)),
(return False)
)
),
nqp::p6bool(nqp::eqaddr(riter.pull-one,IterationEnd))
)
)
)
}
}

sub GATHER(&block) { Seq.new(Rakudo::Iterator.Gather(&block)) }

0 comments on commit d3cac14

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