Skip to content

Commit

Permalink
Clarity and correction in 'Any' document
Browse files Browse the repository at this point in the history
If method .class is not the default .class, may not return a one element list.

Documentation now refers to creating a List with the invocant's .class method.

Makes the language relatively consistent over a number of method descriptions.
  • Loading branch information
Moray committed Aug 10, 2018
1 parent 8730775 commit a87c881
Showing 1 changed file with 53 additions and 42 deletions.
95 changes: 53 additions & 42 deletions doc/Type/Any.pod6
Expand Up @@ -336,15 +336,15 @@ Defined as:
method Array(--> Array:D) is nodal
Coerce the invocant to L<Array>.
Coerces the invocant to L<Array>.
=head2 method List
Defined as:
method List(--> List:D) is nodal
Coerce the invocant to L<List>, using the L<list> method.
Coerces the invocant to L<List>, using the L<list> method.
=head2 serial
Expand All @@ -367,7 +367,7 @@ Defined as:
proto method Hash(|) is nodal
multi method Hash( --> Hash:D)
Coerce the invocant to L<Hash>.
Coerces the invocant to L<Hash>.
=head2 method hash
Expand Down Expand Up @@ -402,23 +402,23 @@ Defined as:
method Slip(--> Slip:D) is nodal
Coerce the invocant to L<Slip>.
Coerces the invocant to L<Slip>.
=head2 method Map
Defined as:
method Map(--> Map:D) is nodal
Coerce the invocant to L<Map>.
Coerces the invocant to L<Map>.
=head2 method Bag
Defined as:
method Bag(--> Bag:D) is nodal
Coerce the invocant to L<Bag>, whereby L<Positionals|/type/Positional>
Coerces the invocant to L<Bag>, whereby L<Positionals|/type/Positional>
are treated as lists of values.
=head2 method BagHash
Expand All @@ -427,7 +427,7 @@ Defined as:
method BagHash(--> BagHash:D) is nodal
Coerce the invocant to L<BagHash>, whereby L<Positionals|/type/Positional>
Coerces the invocant to L<BagHash>, whereby L<Positionals|/type/Positional>
are treated as lists of values.
=head2 method Set
Expand All @@ -436,7 +436,7 @@ Defined as:
method Set(--> Set:D) is nodal
Coerce the invocant to L<Set>, whereby L<Positionals|/type/Positional>
Coerces the invocant to L<Set>, whereby L<Positionals|/type/Positional>
are treated as lists of values.
=head2 method SetHash
Expand All @@ -445,7 +445,7 @@ Defined as:
method SetHash(--> SetHash:D) is nodal
Coerce the invocant to L<SetHash>, whereby L<Positionals|/type/Positional>
Coerces the invocant to L<SetHash>, whereby L<Positionals|/type/Positional>
are treated as lists of values.
=head2 method Mix
Expand All @@ -454,7 +454,7 @@ Defined as:
method Mix(--> Mix:D) is nodal
Coerce the invocant to L<Mix>, whereby L<Positionals|/type/Positional>
Coerces the invocant to L<Mix>, whereby L<Positionals|/type/Positional>
are treated as lists of values.
=head2 method MixHash
Expand All @@ -463,7 +463,7 @@ Defined as:
method MixHash(--> MixHash:D) is nodal
Coerce the invocant to L<MixHash>, whereby L<Positionals|/type/Positional>
Coerces the invocant to L<MixHash>, whereby L<Positionals|/type/Positional>
are treated as lists of values.
=head2 method Supply
Expand All @@ -472,8 +472,8 @@ Defined as:
method Supply(--> Supply:D) is nodal
Coerce the invocant first to a C<list> by applying the invocant's
L«C<.list>|/routine/list» method, and then to a L<Supply>.
Coerces the invocant first to L<List> by applying its
L«C<.list>|/routine/list» method, and then to L<Supply>.
=head2 method min
Expand All @@ -482,7 +482,7 @@ Defined as:
multi method min(--> Any:D)
multi method min(&filter --> Any:D)
Coerces to L<Iterable> and returns the numerically smallest element.
Coerces the invocant to L<Iterable> and returns the numerically smallest element.
If a L<Callable> positional argument is provided, each value is passed
into the filter, and its return value is compared instead of the
Expand All @@ -498,7 +498,7 @@ Defined as:
multi method max(--> Any:D)
multi method max(&filter --> Any:D)
Coerces to L<Iterable> and returns the numerically largest element.
Coerces the invocant to L<Iterable> and returns the numerically largest element.
If a L<Callable> positional argument is provided, each value is passed
into the filter, and its return value is compared instead of the
Expand Down Expand Up @@ -567,23 +567,21 @@ Defined as:
method flatmap(Any:U: &code --> Seq)
Coerces the L<Any> to a C<list> by applying the
Coerces the invocant to L<List> by applying its
L«C<.list>|/routine/list» method and uses
L«C<List.flatmap>|/type/List#method_flatmap» on it.
say Any.flatmap({.reverse}); # OUTPUT: «((Any))␤»
In the case of L<Any>, C<Any.list> returns a 1-item list, as is shown.
=head2 method roll
Defined as:
multi method roll(--> Any)
multi method roll($n --> Seq)
Coerces the invocant L<Any> to a C<list> by applying
the L«C<.list>|/routine/list» method and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.roll>|/type/List#routine_roll» on it.
say Any.roll; # OUTPUT: «(Any)␤»
Expand All @@ -596,8 +594,8 @@ Defined as:
multi method pick(--> Any)
multi method pick($n --> Seq)
Coerces the L<Any> to a C<list> by applying the
L«C<.list>|/routine/list» method and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.pick>|/type/List#routine_pick» on it.
say Any.pick; # OUTPUT: «(Any)␤»
Expand Down Expand Up @@ -661,7 +659,8 @@ Defined as:
method first(Mu $matcher?, :$k, :$kv, :$p, :$end)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.first>|/type/List#routine_first» on it.
say Any.first; # OUTPUT: «(Any)␤»
Expand All @@ -672,7 +671,8 @@ Defined as:
method unique(:&as, :&with --> Seq:D)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.unique>|/type/List#routine_unique» on it.
say Any.unique; # OUTPUT: «((Any))␤»
Expand All @@ -683,7 +683,8 @@ Defined as:
method repeated(:&as, :&with --> Seq)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.repeated>|/type/List#routine_repeated» on it.
say Any.repeated; # OUTPUT: «()␤»
Expand All @@ -694,7 +695,8 @@ Defined as:
method squish(:&as, :&with --> Seq)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.squish>|/type/List#routine_squish» on it.
say Any.squish; # OUTPUT: «((Any))␤»
Expand All @@ -706,7 +708,8 @@ Defined as:
method permutations(--> Seq)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.permutations>|/type/List#routine_permutations» on it.
say Any.permutations; # OUTPUT: «(((Any)))␤»
Expand All @@ -717,7 +720,8 @@ Defined as:
method categorize(&mapper --> Hash:D)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.categorize>|/type/List#routine_categorize» on it.
say Any.categorize({ $_ }); # OUTPUT: «{(Any) => [(Any)]}␤»
Expand All @@ -728,7 +732,8 @@ Defined as:
method classify(&mapper -->Hash:D)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.classify>|/type/List#routine_classify» on it.
say Any.classify({ $_ }); # OUTPUT: «{(Any) => [(Any)]}␤»
Expand All @@ -743,9 +748,10 @@ Defined as:
multi method pairs(Any:U: -->List)
multi method pairs(Any:D: -->List)
Returns an empty L<List> if the invocant is undefined, otherwise
converts the invocant to a L<List> via the C<list> method
and calls L<List.pairs|/type/List#routine_pairs> on it:
Coerces the invocant to L<List> by applying its L«C<.list>|/routine/list» method
and uses L<List.pairs|/type/List#routine_pairs> on it.
Returns an empty L<List> if the invocant is undefined:
say Any.pairs; # OUTPUT: «()␤»
my $a;
Expand All @@ -761,9 +767,10 @@ Defined as:
multi method antipairs(Any:U: -->List)
multi method antipairs(Any:D: -->List)
Applies the method L<List.antipairs|/type/List#routine_antipairs> to the invocant, if it is defined,
after having invoked C<list> on it. If the invocant is not defined,
it returns an empty L<List>:
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L<List.antipairs|/type/List#routine_antipairs> on it.
Returns an empty L<List> if the invocant is undefined:
my $a;
say $a.antipairs; # OUTPUT: «()»
Expand All @@ -778,9 +785,10 @@ Defined as:
multi method kv(Any:U: -->List)
multi method kv(Any:D: -->List)
Returns an empty L<List> if the invocant is not defined, otherwise it
does invoke C<list> on the invocant and then returns the result
of L<List.kv|/type/List#routine_kv> on the latter:
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L<List.kv|/type/List#routine_kv> on it.
Returns an empty L<List> if the invocant is undefined:
my $a;
say $a.kv; # OUTPUT: «()»
Expand Down Expand Up @@ -933,7 +941,8 @@ Defined as:
method combinations(--> Seq)
Treats the C<Any> as a 1-item list and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.combinations>|/type/List#routine_combinations» on it.
say Any.combinations; # OUTPUT: «(() ((Any)))␤»
Expand All @@ -944,7 +953,7 @@ Defined as:
method iterator(--> Iterator)
Coerces the C<Any> to a C<list> by applying the C<.list> method and uses
Coerces the invocant to L<List> by applying its L«C<.list>|/routine/list» method and uses
L«C<iterator>|/type/Iterable#method_iterator» on it.
my $it = Any.iterator;
Expand All @@ -957,7 +966,8 @@ Defined as:
method grep(Mu $matcher, :$k, :$kv, :$p, :$v --> Seq)
Coerces the C<Any> to a C<list> by applying the C<.list> method and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.grep>|/type/List#routine_grep» on it.
Based on C<$matcher> value can be either C<((Any))> or empty List.
Expand Down Expand Up @@ -1026,7 +1036,8 @@ Defined as:
multi method batch(Int:D $batch --> Seq)
multi method batch(Int:D :$elems --> Seq)
Coerces the object to a C<List> by applying the C<.list> method and uses
Coerces the invocant to L<List> by applying
its L«C<.list>|/routine/list» method and uses
L«C<List.batch>|/type/List#method_batch» on it.
=end pod
Expand Down

0 comments on commit a87c881

Please sign in to comment.