Microsoft Store
 

Guard (computing)


 

In computer programming, a guard is a boolean expression that must evaluate to true if the program execution is to continue in the branch in question. The term is used at least in Haskell and Clean programming languages. In Mathematica, guards are called constraints. Guarded commands is a language in Formal methods. Guards can be used to augment pattern matching with the possibility to skip a pattern even if the structure matches. Boolean expressions in conditional statements usually also fit this definition of a guard.

Related Topics:
Boolean - Expression - Haskell - Clean - Mathematica - Guarded commands - Formal methods - Pattern matching - Conditional statement

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In the following Haskell example, the guards occur between each pair of "|" and "=":

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

f x

~ ~ ~ ~ ~ ~ ~ ~ ~ ~