|To:||rakudobug [...] perl.org|
|Date:||Thu, 7 Dec 2017 18:47:47 -0500|
|From:||brian d foy <brian.d.foy [...] gmail.com>|
|Subject:||Can't tail a tail.|
I first asked about this on Stackoverflow: Show quoted textA .tail on a .tail appears to do the wrong thing:
> my $list = <a b c d e f g h i j>;(a b c d e f g h i j) Show quoted text
> $list.tail(5).tailNil But throwing a list in there works: Show quoted text
> $list.tail(5).list.tailj Timo said: .tail and .tail(1) are implemented with Rakudo::Iterator.LastValue and Rakudo::Iterator.LastNValues respectively, which differ quite a bit in implementation. And he figures: tail on the List takes an iterator and skips it ahead $n items. then, the tail method on Seq calls count-only on it to figure out how far to skip ahead to get the last $m items. However, count-only on the first iterator just gives you the total number of items in the original list. It should probably either signal an error when asked for count-only, or it should calculate the proper amount of items left.