4 ms·
That's an odd example, but you can do it in OCaml: match (a, b) with | (1, 1) -> 1 | (1, 0) -> (fix b); 1 | _ -> 0
by enedil 7y ago
That's an odd example, but you can do it in OCaml:
match (a, b) with
| (1, 1) -> 1
| (1, 0) -> (fix b); 1
| _ -> 0
- hedora 7y agoIn C: switch (!!a) & ((!!b) < 1) { case 3: return 1; case 1: fix_b(); return 1; default: return 0; } If you rewrite 3 as “A & B”, this turns into feature flags, and is less crazy looking (not sure arithmetic is allowed in case statements though). Better (regardless of language) is flow like this: if (!b) fix_b(); return a && b;