Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Junctions / Exercises / Exactly one
Solution: Exactly one
Here is a possible solution to the task.
Code
say so one(1, 2, 3) == 2;🦋 You can find the source code in the file any-match.raku.
Output
TrueComments
A
onejunction is true only when exactly one value matches the comparison.Exactly one of
1, 2, 3equals2, so the result isTrue. If two of them matched (or none did), it would beFalse. Thesocollapses the junction to a plain Boolean.
Course navigation
← Exactly one | All even →