Skip to content
Permalink
Browse files

Use the new PredictiveIterator logic

Rather than checking for callability of "count-only" or "bool-only"
  • Loading branch information...
lizmat committed Sep 9, 2018
1 parent faed3a9 commit ca5825b4fc68566b1540e62aa4b7ca46dff8a8c5
Showing with 5 additions and 13 deletions.
  1. +5 −13 src/core/Seq.pm6
@@ -53,7 +53,7 @@ my class Seq is Cool does Iterable does Sequence {
self.is-lazy,
Failure.new(X::Cannot::Lazy.new(action => '.elems')),
nqp::if(
nqp::isconcrete($!iter) && nqp::can($!iter,'count-only'),
nqp::isconcrete($!iter) && nqp::istype($!iter,PredictiveIterator),
$!iter.count-only,
self.cache.elems
)
@@ -62,32 +62,24 @@ my class Seq is Cool does Iterable does Sequence {

method Numeric() {
nqp::if(
nqp::isconcrete($!iter) && nqp::can($!iter,'count-only'),
nqp::isconcrete($!iter) && nqp::istype($!iter,PredictiveIterator),
$!iter.count-only,
self.cache.Numeric
)
}

method Int() {
nqp::if(
nqp::isconcrete($!iter) && nqp::can($!iter,'count-only'),
nqp::isconcrete($!iter) && nqp::istype($!iter,PredictiveIterator),
$!iter.count-only,
self.cache.Int
)
}

method Bool(Seq:D:) {
nqp::if(
nqp::isconcrete($!iter),
nqp::if(
nqp::can($!iter,'bool-only'),
$!iter.bool-only,
nqp::if(
nqp::can($!iter,'count-only'),
?$!iter.count-only,
self.cache.Bool
)
),
nqp::isconcrete($!iter) && nqp::istype($!iter,PredictiveIterator),
$!iter.bool-only,
self.cache.Bool
)
}

0 comments on commit ca5825b

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