Conditions

Comparisons, logic, and the conditional expression.

A comparison answers 1 or 0. There is no separate boolean type: SMath worksheets compute with comparisons as numbers, and this language has to be able to receive them.

span=6⁢m
allowed=4⁢m
toolong=span>allowed=6⁢m>4⁢m=1

Both sides are held in base SI, so a comparison converts before it compares. Neither of these needs a conversion written into it.

imperial=1⁢in<1⁢m=1
strong=1⁢kip>1⁢lbf=1

and, or and not are words. ! is factorial to anyone who has met SMath and & is bitwise to anyone who has met C, so neither is borrowed here.

inrange=span>1⁢mandspan<10⁢m=6⁢m>1⁢mand6⁢m<10⁢m=1
outside=notinrange=not1=0

The conditional is an expression, so it composes with arithmetic and needs no statement form of its own.

overhang={span−allowedif span>allowed0⁢motherwise={6⁢m−4⁢mif 6⁢m>4⁢m0⁢motherwise=2⁢m

Only the arm that is taken is evaluated, which is what lets a conditional guard something that would otherwise fail. bay[0] would be out of bounds.

bay=[3⁢m4⁢m5⁢m]
n=0
chosen={baynif n>00⁢motherwise={baynif 0>00⁢motherwise=0⁢m

Chained without brackets: the else arm reaches as far as it can, so else if is just another conditional inside it.

load=7⁢kN
grade={1if load<5⁢kN2if load<10⁢kN3otherwise={1if 7⁢kN<5⁢kN2if 7⁢kN<10⁢kN3otherwise=2

A function body can be piecewise.

fn stress defined
σ=stress⁡(10⁢kN,2⁢m2)=5000⁢Pa

Substitution shows which way the worksheet went. The arm that did not run is shown as it was written, because it has no values to show.

margin={span−allowedif toolongallowed−spanotherwise={6⁢m−4⁢mif 1allowed−spanotherwise=2⁢m

A verdict in words. A string is a value like any other — it binds to a name, an if chooses between two, and == compares them — and it has no arithmetic at all, which is the whole of what a worksheet does with one.

a=3⁢m
amax=4⁢m
verdict={if a ≤ a_max then "singly reinforced" else "doubly reinforced"if a≤amaxif a ≤ a_max then "singly reinforced" else "doubly reinforced"otherwise={if 3 m ≤ 4 m then "singly reinforced" else "doubly reinforced"if 3⁢m≤4⁢mif 3 m ≤ 4 m then "singly reinforced" else "doubly reinforced"otherwise="singly reinforced"
timber="C24"
isc24=timber=timber == "C24"="C24"="C24" == "C24"=1