Skip to content

Commit

Permalink
Documents RaceSeq, some fixes and adds to type-graph.txt closes #1897
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jul 26, 2019
1 parent a305a94 commit 5b8e85c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/Type/HyperSeq.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Applies C<grep> to the C<HyperSeq> similarly to how it would do it on a Seq.
=for code
my @hyped = (^10000).map(*²).hyper;
@hyped.grep( * %% 3 ).say;
# OUTPUT: «(0 9 36 81 144
# OUTPUT: «(0 9 36 81 144…»
When you use C<hyper> on a C<Seq>, this is the method that is actually called.
Expand Down
84 changes: 84 additions & 0 deletions doc/Type/RaceSeq.pod6
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=begin pod
=TITLE class RaceSeq
=SUBTITLE Performs batches of work in parallel without respecting original
order.
class RaceSeq does Iterable does Sequence { }
An RaceSeq is the intermediate object used when the operator
L<C<race>|/routine/race> is invoked on a L<C<Seq>|/type/Seq>. In general,
it's not intended for direct consumption by the developer.
=head1 Methods
=head2 method iterator
method iterator(RaceSeq:D: --> Iterator:D)
Returns the underlying iterator.
=head2 method grep
method grep(RaceSeq:D: $matcher, *%options)
Applies C<grep> to the C<RaceSeq> similarly to how it would do it on a Seq.
=for code
my @raced = (^10000).map(*²).race;
@raced.grep( * %% 3 ).say;
# OUTPUT: «(0 9 36 81 144 …»
When you use C<race> on a C<Seq>, this is the method that is actually called.
=head2 method map
method map(RaceSeq:D: $matcher, *%options)
Uses maps on the C<RaceSeq>, generally created by application of C<.race> to
a preexisting C<Seq>.
=head2 method invert
method invert(RaceSeq:D:)
Inverts the C<RaceSeq> created from a C<Seq> by C<.race>.
=head2 method race
method race(RaceSeq:D:)
Returns the object.
=head2 method hyper
method hyper(RaceSeq:D:)
Creates a C<HyperSeq> object out of the current one.
=head2 method serial
multi method serial(RaceSeq:D:)
Converts the object to a C<Seq> and returns it.
=head2 method is-lazy
method is-lazy(--> False )
Returns C<False>.
=head2 method sink
Defined as:
method sink(--> Nil)
Sinks the underlying data structure, producing any side effects.
=end pod

# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
2 changes: 2 additions & 0 deletions type-graph.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ role Iterable
role Iterator
role PositionalBindFailover
class Seq is Cool does Iterable does PositionalBindFailover
class RaceSeq does Iterable does Sequence
class HyperSeq does Iterable does Sequence

[Composite]
# Collections: Positional
Expand Down

0 comments on commit 5b8e85c

Please sign in to comment.