Skip to content

Commit

Permalink
Minor changes and reflow
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Aug 14, 2018
1 parent 8167832 commit 5a3133b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
30 changes: 16 additions & 14 deletions doc/Type/Iterable.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ my $a := DNA.new('GAATCC');
.say for $a; # OUTPUT: «(G A A)␤(T C C)␤»
=end code
This example mixes in the Iterable role to offer a new way of iterating over
what is essentially a string (constrained by
L<C<where>|/type/Signature#index-entry-where_clause_(Signature)> to just the
four DNA letters). In the last statement, C<for> actually hooks to the C<iterator> role printing the letters in groups of 3.
This example mixes in the Iterable role to offer a new way of iterating
over what is essentially a string (constrained by
L<C<where>|/type/Signature#index-entry-where_clause_(Signature)> to just
the four DNA letters). In the last statement, C<for> actually hooks to
the C<iterator> role printing the letters in groups of 3.
=head1 Methods
Expand All @@ -44,8 +45,8 @@ Defined as:
method iterator(--> Iterator:D)
Method stub that ensures all classes doing the C<Iterable> role have a method
C<iterator>.
Method stub that ensures all classes doing the C<Iterable> role have a
method C<iterator>.
It is supposed to return an L<Iterator|/type/Iterator>.
Expand All @@ -57,19 +58,20 @@ Defined as:
method flat(--> Iterable)
Returns another L<Iterable> that flattens out all iterables that the first one
returns.
Returns another L<Iterable> that flattens out all iterables that the
first one returns.
For example
say (<a b>, 'c').elems; # OUTPUT: «2␤»
say (<a b>, 'c').flat.elems; # OUTPUT: «3␤»
because C<< <a b> >> is a L<List|/type/List> and thus iterable, so
C<< (<a b>, 'c').flat >> returns C<('a', 'b', 'c')>, which has three elems.
because C<< <a b> >> is a L<List|/type/List> and thus iterable, so C<<
(<a b>, 'c').flat >> returns C<('a', 'b', 'c')>, which has three elems.
Note that the flattening is recursive, so C<((("a", "b"), "c"), "d").flat>
returns C<("a", "b", "c", "d")>, but it does not flatten itemized sublists:
Note that the flattening is recursive, so C<((("a", "b"), "c"),
"d").flat> returns C<("a", "b", "c", "d")>, but it does not flatten
itemized sublists:
say ($('a', 'b'), 'c').perl; # OUTPUT: «($("a", "b"), "c")␤»
Expand All @@ -90,8 +92,8 @@ Defined as:
method hyper(Int(Cool) :$batch = 64, Int(Cool) :$degree = 4 --> Iterable)
Returns another Iterable that is potentially iterated in parallel, with a
given batch size and degree of parallelism.
Returns another Iterable that is potentially iterated in parallel, with
a given batch size and degree of parallelism.
The order of elements is preserved.
Expand Down
25 changes: 13 additions & 12 deletions doc/Type/Iterator.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ role Iterator { }
A C<Iterator> is an object that can generate or provide elements of a
sequence. Users usually don't have to care about iterators, their usage
is hidden behind iteration APIs such as C<for @list { }>, L<map>, L<grep>,
L<head>, L<tail>, L<skip> and list indexing with C<.[$idx]>.
is hidden behind iteration APIs such as C<for @list { }>, L<map>,
L<grep>, L<head>, L<tail>, L<skip> and list indexing with C<.[$idx]>.
The main API is the C<pull-one> method, which either returns the next value,
or the sentinel value C<IterationEnd> if no more elements are available. Each
Expand All @@ -25,11 +25,12 @@ Iterator role.
=head1 IterationEnd
X<|IterationEnd>
Iterators only allow one iteration over the entire sequence. It's forbidden
to make attempts to fetch more data, once C<IterationEnd> has been generated,
and behavior for doing so is undefined. For example, the following L<Seq>
will not cause the L<die> to be called under normal use, because
L<pull-one> will never be called after it returns C<IterationEnd>:
Iterators only allow one iteration over the entire sequence. It's
forbidden to make attempts to fetch more data, once C<IterationEnd> has
been generated, and behavior for doing so is undefined. For example, the
following L<Seq> will not cause the L<die> to be called under normal
use, because L<pull-one> will never be called after it returns
C<IterationEnd>:
=begin code
class SkippingArray is Array {
Expand Down Expand Up @@ -221,11 +222,11 @@ produce more elements to achieve better performance.
say (1 .. ∞).iterator.push-at-least(@array, 10); # OUTPUT: «10␤»
say @array; # OUTPUT: «[1 2 3 4 5 6 7 8 9 10]␤»
The Iterator role implements this method in terms of C<pull-one>. In general, it
is also not intended to be called directly as in the example above. It can be
implemented, if unhappy with this default implementation, by those using this
role. See
L<the documentation for C<push-exactly>|https://docs.perl6.org/type/Iterator#method_push-exactly>
The Iterator role implements this method in terms of C<pull-one>. In
general, it is also not intended to be called directly as in the example
above. It can be implemented, if unhappy with this default
implementation, by those using this role. See L<the documentation for
C<push-exactly>|https://docs.perl6.org/type/Iterator#method_push-exactly>
for an example implementation.
=head2 method push-all
Expand Down
34 changes: 18 additions & 16 deletions doc/Type/Str.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ currently erroneously returns the number of codepoints instead.
multi method encode(Str:D $encoding = 'utf8', :$replacement, Bool() :$translate-nl = False, :$strict)
Returns a L<Blob> which represents the original string in the given encoding and
normal form. The actual return type is as specific as possible, so
C<$str.encode('UTF-8')> returns a C<utf8> object, C<$str.encode('ISO-8859-1')> a
C<buf8>. If C<:translate-nl> is set to C<True>, it will translate newlines from
C<\n> to C<\n\r>, but only in Windows. C<$replacement> indicates how characters
are going to be replaced in the case they are not available in the current
encoding, while C<$strict> indicates whether unmapped codepoints will still
decode; for instance, codepoint 129 which does not exist in C<windows-1252>.
Returns a L<Blob> which represents the original string in the given
encoding and normal form. The actual return type is as specific as
possible, so C<$str.encode('UTF-8')> returns a C<utf8> object,
C<$str.encode('ISO-8859-1')> a C<buf8>. If C<:translate-nl> is set to
C<True>, it will translate newlines from C<\n> to C<\n\r>, but only in
Windows. C<$replacement> indicates how characters are going to be
replaced in the case they are not available in the current encoding,
while C<$strict> indicates whether unmapped codepoints will still
decode; for instance, codepoint 129 which does not exist in
C<windows-1252>.
my $str = "Þor is mighty";
say $str.encode("ascii", :replacement( 'Th') ).decode("ascii");
Expand Down Expand Up @@ -366,8 +368,8 @@ convert those:
say "\c[1337]"; # OUTPUT: «Թ␤»
say '1337'.chr; # OUTPUT: «Թ␤»
I<Note:> before being standardized in 2017.12, this routine was known under
its working name of L<parse-names>, which will be removed in 6.e language.
I<Note:> before being standardized in 2017.12, this routine was known
under its working name of L<parse-names>. This denomination will be removed in the 6.e version.
=head2 routine split
Expand Down Expand Up @@ -1266,27 +1268,27 @@ See also L<trim-trailing> and L<trim-leading>
method trim-trailing(Str:D: --> Str)
Remove the whitespace characters from the end of a string. See also L<trim>.
Removes the whitespace characters from the end of a string. See also L<trim>.
=head2 method trim-leading
method trim-leading(Str:D: --> Str)
Remove the whitespace characters from the beginning of a string. See also L<trim>.
Removes the whitespace characters from the beginning of a string. See also L<trim>.
=head2 method NFC
method NFC(Str:D: --> NFC:D)
Returns a codepoint string in L<NFC|/type/NFC> format (Unicode Normalization
Form C / Composed).
Returns a codepoint string in L<NFC|/type/NFC> format (Unicode
Normalization Form C / Composed).
=head2 method NFD
method NFD(Str:D: --> NFD:D)
Returns a codepoint string in L<NFD|/type/NFD> format (Unicode Normalization
Form D / Decomposed).
Returns a codepoint string in L<NFD|/type/NFD> format (Unicode
Normalization Form D / Decomposed).
=head2 method NFKC
Expand Down

0 comments on commit 5a3133b

Please sign in to comment.