Skip to content

Commit c53ef11

Browse files
committed
Metaoperator normalized
1 parent ad8e495 commit c53ef11

File tree

5 files changed

+50
-47
lines changed

5 files changed

+50
-47
lines changed

doc/Language/haskell-to-p6.pod6

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
55
=SUBTITLE Learning Perl 6 from Haskell, in a nutshell: What do I already know?
66
7-
Haskell and Perl 6 are I<very> different languages. This is obvious. However,
8-
that does not mean there are not similarities or shared ideas! This page
9-
attempts to get a Haskell user up and running with Perl 6. The Haskell user may
10-
find that they need not abandon all of their Haskelly thoughts while scripting
11-
in Perl 6.
7+
Haskell and Perl 6 are I<very> different languages. This is obvious.
8+
However, that does not mean there are not similarities or shared ideas!
9+
This page attempts to get a Haskell user up and running with Perl 6. The
10+
Haskell user may find that they need not abandon all of their Haskelly
11+
thoughts while scripting in Perl 6.
1212
1313
Note that this should not be mistaken for a beginner tutorial or overview of
1414
Perl 6; it is intended as a technical reference for Perl 6 learners with a
@@ -439,8 +439,8 @@ Fold in Haskell is called Reduce in Perl 6.
439439
@numbers.reduce({$^a + $^b}, with => 0)
440440
=end code
441441
442-
However, in Perl 6, if you want to use an infix operator (+ - / % etc) there is a nice little
443-
helper called the Reduction Metaoperator.
442+
However, in Perl 6, if you want to use an infix operator (+ - / % etc)
443+
there is a nice little helper called the Reduction metaoperator.
444444
445445
=begin code
446446
my @numbers = {...};
@@ -459,7 +459,7 @@ associativity attached to the operator/subroutine.
459459
# you can use a subroutine as an infix operator
460460
say 'a' [&two-elem-list] 'b'; # (a b)
461461
462-
# as the reduction prefix meta operator takes an infix operator, it will work there too;
462+
# as the reduction prefix metaoperator takes an infix operator, it will work there too;
463463
[[&two-elem-list]] 1..5; # ((((1 2) 3) 4) 5)
464464
say (1..5).reduce: &two-elem-list; # ((((1 2) 3) 4) 5)
465465

doc/Language/operators.pod6

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,16 @@ L<#prefix ...> etc. stub operators.
116116
Defining custom operators is covered in
117117
L<Defining Operators functions|/language/functions#Defining_Operators>.
118118
119-
=head1 Meta Operators
119+
=head1 Metaoperators
120120
121-
Meta operators can be parameterized with other operators or subroutines in the
122-
same way as functions can take functions as parameters. To use a subroutine as
123-
a parameter, prefix its name with a C<&>. Perl 6 will generate the actual
124-
combined operator in the background, allowing the mechanism to be applied to
125-
user defined operators. To disambiguate chained meta operators, enclose the
126-
inner operator in square brackets. There are quite a few Meta operators with
127-
different semantics as explained, next.
121+
Metaoperators can be parameterized with other operators or subroutines
122+
in the same way as functions can take functions as parameters. To use a
123+
subroutine as a parameter, prefix its name with a C<&>. Perl 6 will
124+
generate the actual combined operator in the background, allowing the
125+
mechanism to be applied to user defined operators. To disambiguate
126+
chained metaoperators, enclose the inner operator in square brackets.
127+
There are quite a few metaoperators with different semantics as
128+
explained, next.
128129
129130
=head1 Substitution Operators
130131
@@ -251,7 +252,7 @@ Although not strictly operators, methods can be used in the same fashion.
251252
$a .= round; # RESULT: «3»
252253
253254
=head1 Negated Relational Operators
254-
X<|! (negation meta operator)>X<|!==>X<|!eq>
255+
X<|! (negation metaoperator)>X<|!==>X<|!eq>
255256
256257
The result of a relational operator returning C<Bool> can be negated by
257258
prefixing with C<!>. To avoid visual confusion with the C<!!> operator,
@@ -268,10 +269,10 @@ There are shortcuts for C<!==> and C<!eq>, namely C<!=> and C<ne>.
268269
say so $release !before $today; # OUTPUT: «False␤»
269270
270271
=head1 Reversed Operators
271-
X<|R,reverse meta operator>
272+
X<|R,reverse metaoperator>
272273
273-
Any infix operator may be called with its two arguments reversed by prefixing
274-
with C<R>. Associativity of operands is reversed as well.
274+
Any infix operator may be called with its two arguments reversed by
275+
prefixing with C<R>. Associativity of operands is reversed as well.
275276
276277
say 4 R/ 12; # OUTPUT: «3␤»
277278
say [R/] 2, 4, 16; # OUTPUT: «2␤»
@@ -290,7 +291,7 @@ list until all elements of the longer list are processed.
290291
say (1, 2, 3, 4) »~» <a b>; # OUTPUT: «(1a 2b 3a 4b)␤»
291292
say (1, 2, 3) »+« (4, 5, 6); # OUTPUT: «(5 7 9)␤»
292293
293-
Assignment meta operators can be I<hyped>.
294+
Assignment metaoperators can be I<hyped>.
294295
295296
my @a = 1, 2, 3;
296297
say @a »+=» 1; # OUTPUT: «[2 3 4]␤»
@@ -381,7 +382,7 @@ You can chain hyper operators to destructure a List of Lists.
381382
say $neighbors »>>+<<» ($p, *); # OUTPUT: «((1 3) (2 2) (2 4) (3 3))␤»
382383
383384
=head1 Reduction Operators
384-
X<|[] (reduction meta operators)>X<|[+] (reduction meta operators)>
385+
X<|[] (reduction metaoperators)>X<|[+] (reduction metaoperators)>
385386
386387
The reduction metaoperator, C<[ ]>, reduces a list with the given infix
387388
operator. It gives the same result as the L<reduce> routine - see there for
@@ -412,7 +413,7 @@ quote it with C<[]> (e.g. C<[\[\x]]>).
412413
say @n[^5]; # OUTPUT: «(1 12 123 1234 12345)␤»
413414
414415
=head1 Cross Operators
415-
X<|X (cross meta operator)>
416+
X<|X (cross metaoperator)>
416417
417418
The cross metaoperator, C<X>, will apply a given infix operator in order of
418419
cross product to all lists, such that the rightmost operator varies most
@@ -421,7 +422,7 @@ quickly.
421422
1..3 X~ <a b> # RESULT: «<1a, 1b, 2a, 2b, 3a, 3b>␤»
422423
423424
=head1 Zip Operators
424-
X<|Z (zip meta operator)>
425+
X<|Z (zip metaoperator)>
425426
426427
The zip metaoperator (which is not the same thing as L<Z|#infix_Z>) will
427428
apply a given infix operator to pairs taken one left, one right, from its
@@ -441,16 +442,16 @@ If an infix operator is not given, C<,> (comma operator) will be used by default
441442
my @l = 1 Z 2; # RESULT: «[(1 2)]»
442443
443444
=head1 Sequential Operators
444-
X<|S,sequential meta operator>
445+
X<|S,sequential metaoperator>
445446
446447
The sequential metaoperator, C<S>, will suppress any concurrency or reordering
447448
done by the optimizer. Most simple infix operators are supported.
448449
449450
say so 1 S& 2 S& 3; # OUTPUT: «True␤»
450451
451-
=head1 Nesting of Meta Operators
452+
=head1 Nesting of Metaoperators
452453
453-
To avoid ambiguity when chaining meta operators, use square brackets to help the
454+
To avoid ambiguity when chaining metaoperators, use square brackets to help the
454455
compiler understand you.
455456
456457
my @a = 1, 2, 3;
@@ -2220,7 +2221,7 @@ values for all C<Z> operators in a chain.
22202221
}
22212222
# OUTPUT: «a:1␤b:2␤c:3␤»
22222223
2223-
The C<Z> operator also exists as a meta operator, in which case the inner
2224+
The C<Z> operator also exists as a metaoperator, in which case the inner
22242225
lists are replaced by the value from applying the operator to the
22252226
list:
22262227
@@ -2239,9 +2240,8 @@ elements vary most rapidly:X<|cross product operator>
22392240
# (2 a 9) (2 b 9) (2 c 9)
22402241
# (3 a 9) (3 b 9) (3 c 9))
22412242
2242-
The C<X> operator also exists as a meta operator, in which case the inner
2243-
lists are replaced by the value from applying the operator to the
2244-
list:
2243+
The C<X> operator also exists as a metaoperator, in which case the inner
2244+
lists are replaced by the value from applying the operator to the list:
22452245
22462246
1..3 X~ <a b c> X~ 9
22472247
# produces (1a9 1b9 1c9 2a9 2b9 2c9 3a9 3b9 3c9)
@@ -2348,8 +2348,9 @@ object.
23482348
If type constrains on variables or containers are present a type check will be
23492349
performed at runtime. On failure C<X::TypeCheck::BindingType> will be thrown.
23502350
2351-
Please note that C<:=> is a compile time construct. As such it can not be
2352-
referred to at runtime and thus can't be used as an argument to meta operators.
2351+
Please note that C<:=> is a compile time construct. As such it can not
2352+
be referred to at runtime and thus can't be used as an argument to
2353+
metaoperators.
23532354
23542355
=head2 infix C«::=»
23552356

doc/Language/testing.pod6

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
=SUBTITLE Writing and running tests in Perl 6
66
77
8-
Testing code is an integral part of software development.
9-
Tests provide automated, repeatable
10-
verifications of code behaviour, and ensures your code works as expected.
8+
Testing code is an integral part of software development. Tests provide
9+
automated, repeatable verifications of code behaviour, and ensures your
10+
code works as expected.
1111
1212
In Perl 6, the L<Test|https://github.com/rakudo/rakudo/blob/master/lib/Test.pm6>
1313
module provides a testing framework. Perl 6's official spectest suite uses C<Test>.
@@ -466,7 +466,8 @@ user-defined infix.
466466
467467
cmp-ok 'my spelling is apperling', '~~', /perl/, "bad speller";
468468
469-
Meta operators cannot be given as a string; pass them as a L<Callable> instead:
469+
Metaoperators cannot be given as a string; pass them as a L<Callable>
470+
instead:
470471
471472
cmp-ok <a b c>, &[!eqv], <b d e>, 'not equal';
472473

doc/Language/traps.pod6

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
55
=SUBTITLE Traps to avoid when getting started with Perl 6
66
7-
When learning a programming language, possibly with the background of being
8-
familiar with another programming language, there are always some things
9-
that can surprise you and might cost valuable time in debugging and
10-
discovery.
7+
When learning a programming language, possibly with the background of
8+
being familiar with another programming language, there are always some
9+
things that can surprise you and might cost valuable time in debugging
10+
and discovery.
1111
1212
This document aims to show common misconceptions in order to avoid them.
1313
@@ -1684,7 +1684,7 @@ it returns a list with L<Bool> values for each requested
16841684
lookup. Non-empty lists always give C<True> when you L<Bool>ify them,
16851685
so the check always succeeds no matter what keys you give it.
16861686
1687-
=head2 Using C<[…]> meta-operator with a list of lists
1687+
=head2 Using C<[…]> metaoperator with a list of lists
16881688
16891689
Every now and then, someone gets the idea that they can use C<[Z]> to
16901690
create the transpose of a list-of-lists:

doc/Type/List.pod6

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ for operators which aren't left-associative:
880880
(2-3-4).say; # OUTPUT: «-5␤»
881881
882882
Since reducing with an infix operator is a common thing to do, the C<[ ]>
883-
meta-operator provides a syntactic shortcut:
883+
metaoperator provides a syntactic shortcut:
884884
885885
# The following all do the same thing...
886886
my @numbers = (1,2,3,4,5);
@@ -946,7 +946,7 @@ for operators which aren't left-associative:
946946
say produce &[-], (2,3,4); # OUTPUT: «(2 -1 -5)␤»
947947
say [\-] (2,3,4); # OUTPUT: «(2 -1 -5)␤»
948948
949-
A triangle meta-operator C<[\ ]> provides a syntactic shortcut for
949+
A triangle metaoperator C<[\ ]> provides a syntactic shortcut for
950950
producing with an infix operator:
951951
952952
# The following all do the same thing...
@@ -1130,7 +1130,8 @@ to apply to each of the cross product items.
11301130
say cross([1, 2, 3], [4, 5, 6], :with(&infix:<*>)).join(",");
11311131
# OUTPUT: «4,5,6,8,10,12,12,15,18␤»
11321132
1133-
The C<X> operator can be combined with another operator as a meta-operator to perform a reduction as well:
1133+
The C<X> operator can be combined with another operator as a
1134+
metaoperator to perform a reduction as well:
11341135
11351136
say ([1, 2, 3] X* [4, 5, 6]).join(",")
11361137
# same output as the previous example
@@ -1186,8 +1187,8 @@ single list of products.
11861187
# 8␤
11871188
# 27␤»
11881189
1189-
The C<Z> form can also be used to perform reduction by implicitly setting the
1190-
C<with> parameter with a meta-operator :
1190+
The C<Z> form can also be used to perform reduction by implicitly
1191+
setting the C<with> parameter with a metaoperator :
11911192
11921193
.say for <1 2 3> Z* [1, 2, 3] Z* (1, 2, 3); # same output
11931194

0 commit comments

Comments
 (0)