Conditional structures: Difference between revisions
→{{header|Langur}}
Langurmonkey (talk | contribs) |
Langurmonkey (talk | contribs) |
||
Line 2,909:
=={{header|Langur}}==
If and given expressions always produce
In the shortened forms, you dispense with the keywords (except the first one).
Line 2,934:
===given===
Given expressions are highly flexible. See
Given expressions are scoped per block. Also, test expressions may contain declarations which are scoped to the entire expression. Conditions (case statements) may not contain declarations.
Line 2,940:
case true: ... # all are true
case false, _: ... # .x == false
case
}</lang>
case or > 100, _, re/abc/: ... # .x > 100 or matching(re/abc/, .z)▼
case ; .a > .b: ... # .a > .b▼
<lang Langur>given .x, .y, != .z {
case _, _, 7; xor .a <= .b: ... # .z == 7 xor .a <= .b▼
case 7 <, 14, 21: ... # 7 < .x and .y == 14 and .z != 21
▲ case or > 100, _, re/abc/: ... # .x > 100 or matching(re/abc/, .z)
▲ case ; .a > .b: ... # .a > .b
▲ case _, _, == 7; xor .a <= .b: ... # .z == 7 xor .a <= .b
default: ...
}</lang>
|