Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Channels / Exercises
Sum a channel
Problem
Create a channel. In a background task (a start block),
send the numbers 1..6 into it and then close it. In the
main program, collect every value with .list and print
their sum. This is the natural shape of a channel: a producer on one
thread, a consumer on another.
Example
The program prints:
21