Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #399 from dbrunton/patch-11
replace Supply.new in grep and map
  • Loading branch information
jonathanstowe committed Feb 16, 2016
2 parents 976fa40 + 438f3f5 commit aa656c6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions doc/Type/Supply.pod
Expand Up @@ -246,10 +246,11 @@ the interval tock, and is incremented by one for each value emitted.
Creates a new supply that only emits those values from the original supply
that smart-match against C<$test>.
my $all = Supply.new;
my $ints = $all.grep(Int);
my $supplier = Supplier.new;
my $all = $supplier.Supply;
my $ints = $all.grep(Int);
$ints.tap(&say);
$all.emit($_) for 1, 'a string', 3.14159; # prints only 1
$supplier.emit($_) for 1, 'a string', 3.14159; # prints only 1
=head2 method map
Expand All @@ -258,10 +259,11 @@ that smart-match against C<$test>.
Returns a new supply that maps each value of the given supply through
C<&mapper> and emits it to the new supply.
my $all = Supply.new;
my $double = $all.map(-> $value { $value * 2 });
my $supplier = Supplier.new
my $all = $supplier.Supply;
my $double = $all.map(-> $value { $value * 2 });
$double.tap(&say);
$all.emit(4); # 8
$supplier.emit(4); # 8
=head2 method batch
Expand Down

0 comments on commit aa656c6

Please sign in to comment.