# New Ticket Created by  "brian d foy" 
# Please include the string:  [perl #132543]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=132543 >


I first asked about this on Stackoverflow:

    https://stackoverflow.com/q/47704428/2766176

A .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)

    > $list.tail(5).tail
    Nil

But throwing a list in there works:

    > $list.tail(5).list.tail
    j

Timo said:

    .tail and .tail(1) are implemented with
    Rakudo::Iterator.LastValue and
    Rakudo::Iterator.LastNValues respectively, which differ
    quite a bit in implementation.
    
https://github.com/rakudo/rakudo/blob/master/src/core/Rakudo/Iterator.pm#L1807

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.

Reply via email to