[ Contents | Previous: Functions ] | Next: Nonlinear Problems ]
A case is Rima's generalisation of an if statement.
The syntax isn't pretty, so you can make any suggestions you like:
value, m1, r1, m2, r2, default = rima.R"value, m1, r1, m2, r2, default"
c = rima.case(value, {{m1, r1}, {m2, r2}}, default)
print(c) --> case value (m1: r1; m2: r2; default: default; )
print(rima.E(c, {value=1, m1=1})) --> r1
If there's more than one match, the case always picks the first:
print(rima.E(c, {value=1, m1=1, m2=1})) --> r1
If an early match isn't yet defined, then the case will remain undefined, even if there's a later match (but following matches and the default will be discarded)
print(rima.E(c, {value=1, m2=1})) --> case 1 (m1: r1; 1: r2; )
If there's a non-match, but no actual match, the non-match is discarded:
print(rima.E(c, {value=1, m1=2})) --> case 1 (m2: r2; default: default; )
[ Contents | Previous: Functions ] | Next: Nonlinear Problems ]