Language

Guards

? (cond) body ..

A guard tests a condition. If it passes, the body runs and the enclosing reducer returns through its ->. If it fails, control falls through to the next statement.

@ grade : a
    n ~ a["score"]
    ? (n >= 90) ("A" >> se_ok) -> ..
    ? (n >= 80) ("B" >> se_ok) -> ..
    ? (n >= 70) ("C" >> se_ok) -> ..
    ("F" >> se_ok) ->
..

{"score": 95} >> grade >> print   ~~ A
{"score": 72} >> grade >> print   ~~ C
{"score": 40} >> grade >> print   ~~ F

A guard's condition can combine comparisons with and, or, and not:

? ((temp > 38) and (not patient["vaccinated"]))
    …
..