Course of Raku / Functional, concurrent, reactive, and web programming / Reactive programming / Supplies / Exercises / Count the emissions
Solution: Count the emissions
Here is a possible solution to the task.
Code
my $count = 0;
Supply.from-list(<a b c d e>).tap(-> $v { $count++ });
say $count;🦋 You can find the source code in the file count-emissions.raku.
Output
5Comments
The tap runs once per emitted value, whatever the values are.
Incrementing
$counteach time gives the total number of values,5.