Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Redirects links
And also closes #2524 again. Fixes definition of operators, and does
some reflow.
  • Loading branch information
JJ committed Jan 21, 2019
1 parent 8d9f331 commit 199fa86
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions doc/Language/operators.pod6
Expand Up @@ -1529,33 +1529,43 @@ if C<$a eqv $b>, then C<$a cmp $b> always returns C<Order::Same>.
=head2 infix C<coll>
Defined as:
Defined asN<These are not yet implemented in the JVM>:
multi sub infix:<coll>(Str:D \a, Str:D \b --> Order:D)
multi sub infix:<coll>(Cool:D \a, Cool:D \b --> Order:D)
multi sub infix:<coll>(Pair:D \a, Pair:D \b)
multi sub infix:<coll>(Str:D \a, Str:D \b)
multi sub infix:<coll>(Pair:D \a, Pair:D \b --> Order:D)
C<coll> is a sorting operator that takes pairs of C<Str>s, C<Cool>s or C<Pair>s and returns an C<Order> that uses the C<$*COLLATION> order. The default behavior disregards diacritic marks and capitalization, for instance.
C<coll> is a sorting operator that takes pairs of C<Str>s, C<Cool>s or C<Pair>s
and returns an C<Order> that uses the C<$*COLLATION> order. The default behavior
disregards diacritic marks and capitalization, for instance.
say "b" cmp "à"; # OUTPUT: «Less␤»
say "b" coll "à"; # OUTPUT: «More␤»
In the first case, lexicographic or codepoint order is taken into account. In the second, which uses C<coll>, the diacritic is not considered and sorting happens according to intuitive order.
In the first case, lexicographic or codepoint order is taken into account. In
the second, which uses C<coll>, the diacritic is not considered and sorting
happens according to intuitive order.
=head2 infix C«unicmp»
Defined asN<These are not yet implemented in the JVM>:
multi sub infix:<unicmp>(Str:D \a, Str:D \b --> Order:D)
multi sub infix:<unicmp>(Pair:D \a, Pair:D \b)
multi sub infix:<unicmp>(Pair:D \a, Pair:D \b --> Order:D)
multi sub infix:<coll>(Pair:D \a, Pair:D \b --> Order:D)
Unlike the cmp operator which sorts according to codepoint, C<unicmp> and
C<coll> sort according to how most users would expect, that is, disregarding aspects of the particular character like capitalization.
C<coll> sort according to how most users would expect, that is, disregarding
aspects of the particular character like capitalization.
say 'a' unicmp 'Z'; # Less
say 'a' coll 'Z'; # Less
say 'a' cmp 'Z'; # More
The main difference between C<coll> and C<unicmp> is that the behavior of the former can be changed by the L<C<$*COLLATION>|/language/experimental#index-entry-%24%2ACOLLATION-%24%2ACOLLATION> dynamic variable.
The main difference between C<coll> and C<unicmp> is that the behavior of the
former can be changed by the
L<C<$*COLLATION>|/type/Any#index-entry-%24*COLLATION-%24*COLLATION> dynamic
variable.
=head2 infix C«leg»
Expand All @@ -1564,7 +1574,8 @@ The main difference between C<coll> and C<unicmp> is that the behavior of the fo
X<String three-way comparator>. Short for I<less, equal or greater?>.
Coerces both arguments to L<Str|/type/Str> and then does a lexicographic comparison.
Coerces both arguments to L<Str|/type/Str> and then does a lexicographic
comparison.
say 'a' leg 'b'; # OUTPUT: «Less␤»
say 'a' leg 'a'; # OUTPUT: «Same␤»
Expand Down

0 comments on commit 199fa86

Please sign in to comment.