Common methods of sequences
does PositionalBindFailover
This role implements a series of methods for converting sequences and accessing their elements. These methods should work on all sequences: serial Seq, ordered parallel HyperSeq, and unordered parallel RaceSeq.
These methods have in common that they all access the underlying iterator if the sequence has not been cached yet. Therefore they will throw an error of type X::Seq::Consumed if called on a Seq
that was already consumed.
multi method Str(::?CLASS:)
Stringifies the cached sequence.
multi method Stringy(::?CLASS:)
Calls .Stringy
on the cached sequence.
method Numeric(::?CLASS:)
Returns the number of elements in the cached sequence.
multi method AT-POS(::?CLASS: Int )multi method AT-POS(::?CLASS: int )
Returns the element at position $idx
in the cached sequence.
multi method EXISTS-POS(::?CLASS: Int )multi method EXISTS-POS(::?CLASS: int )
Returns a Bool
indicating whether there is an element at position $idx
in the cached sequence.
method eager(::?CLASS: --> List)
Returns an eagerly evaluated List based on the invocant sequence, and marks it as consumed. If called on an already consumed Seq
, throws an error of type X::Seq::Consumed.
my = lazy 1..5;say .is-lazy; # OUTPUT: «True»say .eager; # OUTPUT: «(1 2 3 4 5)»say .eager;CATCH# OUTPUT: «Throws exception if already consumed»
method fmt( = '%s', = ' ' --> Str)
multi method gist(::?CLASS:)