# routine ...

Documentation for routine `...`

assembled from the following types:

# language documentation Operators

From Operators

## (Operators) infix ...

multi sub infix:<...>(**@) is assoc<list>multi sub infix:<...^>(**@) is assoc<list>multi sub infix:<^...>(**@) is assoc<list>multi sub infix:<^...^>(**@) is assoc<list>

The sequence operator, which can be written either as `...`

or as `…`

, with variants `...^`

, `^...`

, `^...^`

, `…^`

, `^…`

and `^…^`

, will produce (possibly lazy) generic sequences on demand. Such sequences are of the `Seq`

type.

The variants of the operator with an initial caret, `^...`

, `^...^`

, `^…`

and `^…^`

, produce sequences that do not contain the initial element.

The variants of the operator with a final caret, `...^`

, `^...^`

, `…^`

and `^…^`

, produce sequences that do not contain the final element.

Note: the variants `^...`

, `^...^`

, `^…`

and `^…^`

have been available in Rakudo compiler starting from 2020.05 release.

The left-hand side of the operator specify the initial elements; it may include a generator after the first element or elements. The right-hand side will have an endpoint, which can be `Inf`

or `*`

for "infinite" lists (that is, *lazy* lists whose elements are only produced on demand), an expression which will end the sequence when `True`

, or other elements such as Junctions.

The sequence operator invokes the generator with as many arguments as necessary. The arguments are taken from the initial elements and the already generated elements. The default generator is `*.`

succ or `*.`

pred, depending on how the end points compare:

say 1 ... 4; # OUTPUT: «(1 2 3 4)»say 4 ... 1; # OUTPUT: «(4 3 2 1)»say 1 ^... 4; # OUTPUT: «(2 3 4)»say 1 ...^ 4; # OUTPUT: «(1 2 3)»say 1 ^...^ 4; # OUTPUT: «(2 3)»say 'a' ... 'e'; # OUTPUT: «(a b c d e)»say 'e' ... 'a'; # OUTPUT: «(e d c b a)»

An endpoint of `*`

(Whatever), `Inf`

or `∞`

generates on demand an infinite sequence, with a default generator of `*.succ`

say (1 ... *)[^5]; # OUTPUT: «(1 2 3 4 5)»

Custom generators need to be the last element of the list before the '...' operator. This one takes two arguments, and generates the eight first Fibonacci numbers

say (1, 1, -> , ... *)[^8]; # OUTPUT: «(1 1 2 3 5 8 13 21)»# same but shortersay (1, 1, * + * ... *)[^8]; # OUTPUT: «(1 1 2 3 5 8 13 21)»

Of course the generator can also take only one argument.

say 5, ... 40; # OUTPUT: «5 10 20 40»

There must be at least as many initial elements as arguments to the generator.

Without a generator and with more than one initial element and all initial elements numeric, the sequence operator tries to deduce the generator. It knows about arithmetic and geometric sequences.

say 2, 4, 6 ... 12; # OUTPUT: «(2 4 6 8 10 12)»say 1, 2, 4 ... 32; # OUTPUT: «(1 2 4 8 16 32)»say 1, 2, 4 ^... 32; # OUTPUT: «(2 4 8 16 32)»say 1, 2, 4 ^...^ 32; # OUTPUT: «(2 4 8 16)»

If the endpoint is not `*`

, it's smartmatched against each generated element and the sequence is terminated when the smartmatch succeeded. The final element is excluded of the sequence if a sequence operator variant with a final caret is used, it is included otherwise.

This allows you to write

say 1, 1, * + * ...^ *>= 100;# OUTPUT: «(1 1 2 3 5 8 13 21 34 55 89)»

to generate all Fibonacci numbers up to but excluding 100.

The `...`

operators consider the initial values as "generated elements" as well, so they are also checked against the endpoint:

my = 4;say 1, 2, 4, 8, 16 ... ;# OUTPUT: «(1 2 4)»

# language documentation Operators

From Operators

## (Operators) listop ...

Called the *yada, yada, yada* operator or *stub* operator, if it's the only statement in a routine or type, it marks that routine or type as a stub (which is significant in the context of pre-declaring types and composing roles).

If the `...`

statement is executed, it calls fail, with the default message `Stub code executed`

.