Sequence Reference
Common methods of sequences
What it is #
Position in the hierarchy #
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method Str #
multi method Str(::?CLASS:D:)
Stringifies the cached sequence.
method Stringy #
multi method Stringy(::?CLASS:D:)
Calls .Stringy on the cached sequence.
method Numeric #
method Numeric(::?CLASS:D:)
Returns the number of elements in the cached sequence.
method AT-POS #
multi method AT-POS(::?CLASS:D: Int:D $idx)
multi method AT-POS(::?CLASS:D: int $idx)
Returns the element at position $idx in the cached sequence.
method EXISTS-POS #
multi method EXISTS-POS(::?CLASS:D: Int:D $idx)
multi method EXISTS-POS(::?CLASS:D: int $idx)
Returns a Bool indicating whether there is an element at position $idx in the cached sequence.
method eager #
method eager(::?CLASS:D: --> List:D)
Returns List:D.
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.
method fmt #
method fmt($format = '%s', $separator = ' ' --> Str:D)
Returns Str:D.
method gist #
multi method gist(::?CLASS:D:)
Returns the gist of the cached sequence.
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
1 doc-drift · 2 no-output · 1 not-runnable
role Sequence does PositionalBindFailover { }Not executed: the documentation states no expected output for this example.
my $s = lazy 1..5;
Not executed: the documentation states no expected output for this example.
say $s.is-lazy; # OUTPUT: «True» say $s.eager; # OUTPUT: «(1 2 3 4 5)»
Neither engine can run this in isolation — the example depends on context from the surrounding text.
say $s.eager;
CATCH {
when X::Seq::Consumed {
say 'Throws exception if already consumed';
}
}
# OUTPUT: «Throws exception if already consumed»Throws exception if already consumed
Both engines agree; the documentation states something else. Trust the engines.