Skip to content

Commit

Permalink
Improves push-at-least refs #1395
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jun 12, 2018
1 parent 9f1f046 commit 4a5c966
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions doc/Type/Iterator.pod6
Expand Up @@ -180,7 +180,13 @@ for $þor -> $first, $second {
}
=end code
This code, which groups DNA chains in triplets (usually called I<codons>) returns those codons when requested in a loop; if too many are requested, like in the first case C«for $b -> $a, $b, $c», it simply does not enter the loop since C<push-exactly> will return C<IterationEnd> since it is not able to serve the request for exactly 3 codons. In the second case, however, it requests exactly two codons in each iteration of the loop; C<push-exactly> is being called with the number of loop variables as the C<$count> variable.
This code, which groups DNA chains in triplets (usually called I<codons>)
returns those codons when requested in a loop; if too many are requested, like
in the first case C«for $b -> $a, $b, $c», it simply does not enter the loop
since C<push-exactly> will return C<IterationEnd> since it is not able to serve
the request for exactly 3 codons. In the second case, however, it requests
exactly two codons in each iteration of the loop; C<push-exactly> is being
called with the number of loop variables as the C<$count> variable.
=head2 method push-at-least
Expand All @@ -203,7 +209,12 @@ 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>.
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

0 comments on commit 4a5c966

Please sign in to comment.