Skip to content

Commit 2be59b3

Browse files
committed
document sequence operator variants ^... and ^...^ ref #3360
while here add output to an example for this operator
1 parent 679ea78 commit 2be59b3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

doc/Language/operators.pod6

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ assigned to that level (column labeled C<A>), and some exemplary operators
6565
R | Item assignment | = => \+= -= **= xx=
6666
L | Loose unary | so not
6767
X | Comma operator | , :
68-
X | List infix | Z minmax X X~ X* Xeqv ... … ...^ …^
68+
X | List infix | Z minmax X X~ X* Xeqv ... … ...^ …^ ^... ^… ^...^ ^…^
6969
R | List prefix | print push say die map substr ... [\+] [*] any Z=
7070
X | Loose and | and andthen notandthen
7171
X | Loose or | or xor orelse
@@ -3089,15 +3089,22 @@ lists are replaced by the value from applying the operator to the list:
30893089
# produces (1a9 1b9 1c9 2a9 2b9 2c9 3a9 3b9 3c9)
30903090
30913091
=head2 infix C«...»
3092-
X<|...,operators>X<|...^,operators>X<|…,operators>X<|…^,operators>
3092+
X<|...,operators>X<|...^,operators>X<|^...,operators>X<|^...^,operators>
3093+
X<|…,operators>X<|…^,operators>X<|^…,operators>X<|^…^,operators>
30933094
X<|lazy list,…>
30943095
30953096
multi sub infix:<...>(**@) is assoc<list>
30963097
multi sub infix:<...^>(**@) is assoc<list>
3098+
multi sub infix:<^...>(**@) is assoc<list>
3099+
multi sub infix:<^...^>(**@) is assoc<list>
30973100
30983101
The X<sequence operator>, which can be written either as C<...> or as
3099-
C<> (with variants C<...^> and C<…^>) will produce (possibly lazy)
3100-
generic sequences on demand.
3102+
C<> (with variants C<...^>, C<^...>, C<^...^>, C<…^>, C<^…> and C<^…^>)
3103+
will produce (possibly lazy) generic sequences on demand.
3104+
3105+
Note: the sequence operator variants C<^...>, C<^...^>, C<^…> and
3106+
C<^…^> have been available in Rakudo compiler starting from 2020.05
3107+
release.
31013108
31023109
The left-hand side will always include the initial elements; it may include a
31033110
generator too (after the first element or elements). The right-hand side will
@@ -3148,11 +3155,12 @@ knows about arithmetic and geometric sequences.
31483155
If the endpoint is not C<*>, it's smartmatched against each generated
31493156
element and the sequence is terminated when the smartmatch succeeded.
31503157
For the C<...> operator, the final element is included, for the C<...^>
3151-
operator it's excluded.
3158+
and the C<^...^> operators it's excluded.
31523159
31533160
This allows you to write
31543161
31553162
say 1, 1, * + * ...^ *>= 100;
3163+
# OUTPUT: «(1 1 2 3 5 8 13 21 34 55 89)␤»
31563164
31573165
to generate all Fibonacci numbers up to but excluding 100.
31583166
@@ -3163,6 +3171,11 @@ well, so they are also checked against the endpoint:
31633171
say 1, 2, 4, 8, 16 ... $end;
31643172
# OUTPUT: «(1 2 4)␤»
31653173
3174+
The C<^...> and C<^...^> operators excludes the initial element.
3175+
3176+
say 1, 2, 4 ^... 128; # OUTPUT: «(2 4 8 16 32 64 128)␤»
3177+
say 1, 2, 4 ^...^ 128; # OUTPUT: «(2 4 8 16 32 64)␤»
3178+
31663179
=head1 List prefix precedence
31673180
31683181
X<|list =>

0 commit comments

Comments
 (0)