diff --git a/src/core/Any-iterable-methods.pm b/src/core/Any-iterable-methods.pm index 6de8bdbd18a..2810157f14b 100644 --- a/src/core/Any-iterable-methods.pm +++ b/src/core/Any-iterable-methods.pm @@ -1823,6 +1823,9 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?" Rakudo::Iterator.AllButLastNValues(self.iterator,-($w(0).Int)) ) } + multi method head(Any:D: Callable:D $cond) { + Seq.new(Rakudo::Iterator.While(self.iterator,$cond)) + } multi method head(Any:D: $n) { Seq.new(Rakudo::Iterator.NextNValues(self.iterator,$n)) } @@ -1838,19 +1841,24 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?" $pulled ) } - multi method tail(Any:D: $n) { + multi method tail(Any:D: WhateverCode $w) { Seq.new( nqp::if( - nqp::istype($n,WhateverCode) - && nqp::isgt_i((my $skip := -($n(0).Int)),0), + nqp::isgt_i((my $skip := -($w(0).Int)),0), nqp::stmts( (my $iterator := self.iterator).skip-at-least($skip), $iterator ), - Rakudo::Iterator.LastNValues(self.iterator,$n,'tail') + self.iterator ) ) } + multi method tail(Any:D: Callable:D $w) { + Seq.new(Rakudo::Iterator.Until(self.iterator,$w)) + } + multi method tail(Any:D: $n) { + Seq.new(Rakudo::Iterator.LastNValues(self.iterator,$n,'tail')) + } proto method minpairs(|) {*} multi method minpairs(Any:D:) {