Course of Raku / Functional, concurrent, reactive, and web programming / Reactive programming / react and whenever / Exercises
Two whenevers
Problem
Track a bank balance fed by two streams with opposite
roles. Create two named supplies — deposits from
100, 50, 200 and withdrawals from 30, 120 —
and, in one react block with two whenever
blocks, add every deposit to the balance and
subtract every withdrawal from it. Print the final
balance.
Example
The program prints:
200Solution
Course navigation
← Solution: Sort into two arrays | Solution: Two whenevers →