5 ms·
If you extend the `catch` matching to compound values this isn’t even that bad. let fizzbuzz = func(fizzbuzz, x, max) { try { hurl [x % 3, x % 5
by gqcwwjtg 3y ago
If you extend the `catch` matching to compound values this isn’t even that bad.
let fizzbuzz = func(fizzbuzz, x, max) {
try {
hurl [x % 3, x % 5];
}
catch ([ true, true]) { print("FizzBuzz"); }
catch ([false, true]) { print("Buzz"); }
catch ([ true, false]) { print("Fizz"); }
catch ([false, false]) { print(x); }
try { hurl x; }
catch (max) {}
catch (x) {
fizzbuzz(fizzbuzz, x + 1, max);
}
}
- chii 3y agoand if you just renamed the `catch` to `case`, it almost looks like a regular language. Who cares how it does the jumps in the implementation! ;D