Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor reflow and rewriting
  • Loading branch information
JJ committed Jan 11, 2019
1 parent 764b1c2 commit 18b3e10
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/Language/control.pod6
Expand Up @@ -103,7 +103,7 @@ second statement. C<$c> will never get a value.
=head1 X<Phasers|control flow,Phasers>
Blocks may have phasers: special labeled blocks that break their execution
Blocks may have I<phasers>: special labeled blocks that break their execution
into phases that run in particular phases. See the page
L<phasers|/language/phasers> for the details.
Expand Down
46 changes: 25 additions & 21 deletions doc/Type/Any.pod6
Expand Up @@ -826,7 +826,8 @@ Returns an empty L<List|/type/List> if the invocant is undefined:
=head2 method toggle
B<EXPERIMENTAL routine> whose behaviour may change (early implementation exists in Rakudo compiler 2017.12+)
B<EXPERIMENTAL routine> whose behaviour may change (early implementation exists
in Rakudo compiler 2017.12+)
Defined as:
Expand All @@ -836,25 +837,26 @@ L<Iterates|/routine/iterator> over the invocant, producing a L<Seq|/type/Seq>, t
whether the received values are propagated to the result on and off, depending
on the results of calling L<Callables|/type/Callable> in C<@conditions>:
say (1..15).toggle(* < 5, * > 10, * < 15); # OUTPUT: «(1 2 3 4 11 12 13 14)␤»
say (1..15).toggle(:off, * > 2, * < 5, * > 10, * < 15); # OUTPUT: «(3 4 11 12 13 14)␤»
=for code
say (1..15).toggle(* < 5, * > 10, * < 15); # OUTPUT: «(1 2 3 4 11 12 13 14)␤»
say (1..15).toggle(:off, * > 2, * < 5, * > 10, * < 15); # OUTPUT: «(3 4 11 12 13 14)␤»
Imagine a switch that's either on or off (C<True> or C<False>), and values are
produced if it's on. By default, the initial state of that switch is in "on"
position, unless C<:$off> is set to a true value, in which case the initial
state will be "off".
A L<Callable|/type/Callable> from the L<head|/routine/head> of C<@conditions> is taken (if any are available)
and it becomes the current tester. Each value from the original sequence is
tested by calling the tester L<Callable|/type/Callable> with that value. The state of our
imaginary switch is set to the return value from the tester: if it's truthy,
set switch to "on", otherwise set it to "off".
A L<Callable|/type/Callable> from the L<head|/routine/head> of C<@conditions> is
taken (if any are available) and it becomes the current tester. Each value from
the original sequence is tested by calling the tester L<Callable|/type/Callable>
with that value. The state of our imaginary switch is set to the return value
from the tester: if it's truthy, set switch to "on", otherwise set it to "off".
Whenever the switch is I<toggled> (i.e. switched from "off" to "on" or
from "on" to "off"), the current tester L<Callable|/type/Callable> is replaced by the next
L<Callable|/type/Callable> in C<@conditions>, if available, which will be used to test any
further values. If no more tester Callables are available, the switch will
remain in its current state until the end of iteration.
Whenever the switch is I<toggled> (i.e. switched from "off" to "on" or from
"on" to "off"), the current tester L<Callable|/type/Callable> is replaced by the
next L<Callable|/type/Callable> in C<@conditions>, if available, which will be
used to test any further values. If no more tester Callables are available, the
switch will remain in its current state until the end of iteration.
=begin code
# our original sequence of elements:
Expand Down Expand Up @@ -882,8 +884,9 @@ remain in its current state until the end of iteration.
# will remain off for the rest of the sequence.
=end code
Since the toggle of the switch's state loads the next tester L<Callable|/type/Callable>,
setting C<:$off> to a C<True> value affects when first tester is discarded:
Since the toggle of the switch's state loads the next tester
L<Callable|/type/Callable>, setting C<:$off> to a C<True> value affects when
first tester is discarded:
=begin code
# our original sequence of elements:
Expand Down Expand Up @@ -921,7 +924,9 @@ Defined as:
method tree(--> Any)
Returns the class if it's undefined or if it's not iterable, returns the result of applying the C<tree> method to the elements if it's L<Iterable|/type/Iterable>.
Returns the class if it's undefined or if it's not iterable, returns the result
of applying the C<tree> method to the elements if it's
L<Iterable|/type/Iterable>.
say Any.tree; # OUTPUT: «Any␤»
Expand Down Expand Up @@ -998,11 +1003,10 @@ Defined as:
proto method append(|) is nodal {*}
multi method append(Any:U \SELF: |values --> Array)
In the case the instance is not a positional-thing, it instantiate it
as a new L<Array|/type/Array>, otherwise clone the current
instance.
After that, it appends the values passed as arguments to
the array obtained calling L«C<Array.append>|/type/Array#method_append» on it.
In the case the instance is not a positional-thing, it instantiates it as a new
L<Array|/type/Array>, otherwise clone the current instance. After that, it
appends the values passed as arguments to the array obtained calling
L«C<Array.append>|/type/Array#method_append» on it.
my $a;
say $a.append; # OUTPUT: «[]␤»
Expand Down

0 comments on commit 18b3e10

Please sign in to comment.