Index: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Home > Guard statement
A conditional statement in Haskell whose right-hand side will only be evaluated if the guard statement evaluates to true. A list of guard statements are normally evaluated in a top to bottom order. f x
| x > 0 = 1
| otherwise = 0
The guard statements occur after each "|" and before the "=".
Similar to the mathematic notation:
In this case the guard conditions are the "if" and "otherwise" statements.
Read more »