Skip to content

Commit

Permalink
Fixed formatting and some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Olof Hendig committed Jun 24, 2017
1 parent 7668614 commit 3b409cc
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions doc/Type/List.pod6
Expand Up @@ -74,13 +74,13 @@ check for the absence of elements.
}
# OUTPUT: «True␤True␤True␤»
Coercion to Bool also indicates if the List got any elements.
Coercion to C<Bool> also indicates if the C<List> got any elements.
my @a;
say [@a.elems, @a.Bool, ?@a]; # OUTPUT: «[0 False False]␤»
@a.push: 42;
say [@a.elems, @a.Bool, ?@a]; # OUTPUT: «[1 True True]␤»
say 'empty' unless @a; # OUTPUT: «()␤»
say 'empty' unless @a; # no output
=head1 Methods
Expand Down Expand Up @@ -113,7 +113,7 @@ Defined as:
sub keys($list --> Seq:D)
method keys(List:D: --> Seq:D)
Returns a sequence of indexes into the list (e.g., 0..(@list.elems-1)).
Returns a sequence of indexes into the list (e.g., C<0..(@list.elems-1)>).
say (1,2,3,4).keys; # OUTPUT: «0..3␤»
Expand Down Expand Up @@ -248,7 +248,7 @@ Defined as:
method flatmap(List:D: &code --> Seq:D)
Like L<C<map|/type/Any#method_flat>> iterates over the elements of the invocant
Like L«C<map>|/type/Any#method_flat» iterates over the elements of the invocant
list, feeding each element in turn to the code reference, and assembling the
return values from these invocations in a result list.
Expand All @@ -259,15 +259,15 @@ not confusing like C<.flatmap>.
Unlike C<map> it flattens non-itemized lists and arrays, so
## flatmap
my @list = ('first1', ('second2', ('third3', 'third4'), 'second5'), 'first6')
my @list = ('first1', ('second2', ('third3', 'third4'), 'second5'), 'first6');
say @list.flatmap({.reverse}).perl;
# OUTPUT «("first1", "second5", "third3", "third4", "second2", "first6").Seq»
# OUTPUT «("first1", "second5", "third3", "third4", "second2", "first6").Seq»
## map
say @list.map({"$_ was a {.^name}"}).perl;
# OUTPUT «(("first1",).Seq, ("second5", ("third3", "third4"), "second2").Seq, ("first6",).Seq).Seq»
# OUTPUT «("first1 was a Str", "second2 third3 third4 second5 was a List", "first6 was a Str").Seq»
## .map .flat has the same output as .flatmap
say @list.map({.reverse}).flat.perl
# OUTPUT «("first1", "second5", "third3", "third4", "second2", "first6").Seq»
# OUTPUT «("first1", "second5", "third3", "third4", "second2", "first6").Seq»
=head2 method gist
Expand All @@ -281,16 +281,16 @@ ellipsis if the List has more than 100 elements. If List
L«C<is-lazy>|/routine/is-lazy», returns string C«'(...)'»
=begin code
put (1, 2, 3).gist; # OUTPUT «(1 2 3)␤»
put (1..∞).List.gist; # OUTPUT «(...)␤»
put (1..200).List.gist;
# OUTPUT:
# (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
# 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
# 96 97 98 99 100 ...)
put (1, 2, 3).gist; # OUTPUT «(1 2 3)␤»
put (1..∞).List.gist; # OUTPUT «(...)␤»
put (1..200).List.gist;
# OUTPUT:
# (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
# 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
# 96 97 98 99 100 ...)
=end code
=head2 routine grep
Expand Down Expand Up @@ -346,7 +346,7 @@ Defined as:
method first(List:D: Mu $matcher?, :$k, :$kv, :$p, :$end)
Returns the first item of the list which smart-matches against C<$matcher>,
returns Nil when no values match. The optional named parameter C<:end>
returns C<Nil> when no values match. The optional named parameter C<:end>
indicates that the search should be from the B<end> of the list, rather than
from the start.
Expand Down Expand Up @@ -396,8 +396,8 @@ Examples:
say ^10 .head(5); # OUTPUT: «(0 1 2 3 4)␤»
say ^Inf .head(5); # OUTPUT: «(0 1 2 3 4)␤»
say ^10 .head; # OUTPUT: «(0)␤»
say ^Inf .head; # OUTPUT: «(0)␤»
say ^10 .head; # OUTPUT: «0␤»
say ^Inf .head; # OUTPUT: «0␤»
=head2 method tail
Expand Down Expand Up @@ -425,7 +425,7 @@ Defined as:
method categorize(List:D: &mapper --> Hash:D)
Transforms a list of values into a hash representing the categorizations
of those values according to a mapper; each hash key represents one possible
of those values according to C<&mapper>; each hash key represents one possible
categorization for one or more of the incoming list values, and the
corresponding hash value contains an array of those list values categorized
by the mapper into the category of the associated key.
Expand All @@ -441,8 +441,8 @@ Example:
$i %% 2 ?? 'even' !! 'odd',
$i.is-prime ?? 'prime' !! 'not prime'
}
say categorize &mapper, (1, 7, 6, 3, 2); # OUTPUT: «{even => [6 2], not prime => [1 6],
# odd => [1 7 3], prime => [7 3 2]}␤»
say categorize &mapper, (1, 7, 6, 3, 2); # OUTPUT: «{even => [6 2], not prime => [1 6],
# odd => [1 7 3], prime => [7 3 2]}␤»
=head2 routine classify
Expand All @@ -452,7 +452,7 @@ Defined as:
method classify(List:D: &mapper --> Hash:D)
Transforms a list of values into a hash
representing the classification of those values according to a mapper;
representing the classification of those values according to C<&mapper>;
each hash key represents the classification for one or more of the
incoming list values, and the corresponding hash value contains
an array of those list values classified by the mapper into the category
Expand Down Expand Up @@ -560,7 +560,7 @@ Examples:
say <a b c d e>.pick; # OUTPUT: «b␤»
say <a b c d e>.pick: 3; # OUTPUT: «(c a e)␤»
say <a b c d e>.pick: *; # OUTPUT: «(e d a b c)␤»
say <a b c d e>.pick: *; # OUTPUT: «(e d a b c)␤»
=head2 routine roll
Expand Down Expand Up @@ -596,7 +596,7 @@ Defined as:
Evaluates all elements in the list eagerly, and returns them as a list.
say (1,2,3,4,5).eager; # OUTPUT: «1 2 3 4 5␤»
say (1,2,3,4,5).eager; # OUTPUT: «(1 2 3 4 5)␤»
=head2 routine reverse
Expand All @@ -605,7 +605,7 @@ Defined as:
multi sub reverse(*@list --> Seq:D)
multi method reverse(List:D: --> Seq:D)
Returns a L«C<Seq>|/type/Seq> with the same elements in reverse order.
Returns a L«C<Seq>|/type/Seq» with the same elements in reverse order.
Note that C<reverse> always refers to reversing elements of a list;
to reverse the characters in a string, use L<flip>.
Expand Down

0 comments on commit 3b409cc

Please sign in to comment.