the conditional function
ifelse(conditional expression, true expression, false expression)
`if`(conditional expression, true expression, false expression)
The ifelse(c,a,b) function requires three arguments and returns the evaluation of the second or third, depending on the truth value of the first.
The first argument a must be a conditional expression; if it evaluates to true, b is evaluated and returned. If a evaluates to false or FAIL, then c is evaluated and returned.
The name `if` is an alias for ifelse. When using this name, if must be enclosed in back quotes (left single quotes) because if is a Maple reserved word.
A conditional expression is any Boolean expression formed using the relational operators ( <, <=, >, >=, =, <> ), the logical operators (and, or, not), and the logical names (true, false, FAIL).
When a conditional expression is evaluated in this context, it must evaluate to true, false, or FAIL; otherwise, an error occurs.
The ifelse function is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
a ≔ 3;b ≔ 5
The conditional operator can be used inside an equation. Since b (5) is not less than a (3), the result of the inner ifelse command will be the false expression, b, which is used as part of the calculation.
Using ifelse with NULL
Since a is less than b, x is assigned NULL. Unlike every other function call, which removes NULLs from the calling sequence, NULL can be used with the ifelse operator.
x ≔ ifelse⁡a<b,NULL,b
Download Help Document
What kind of issue would you like to report? (Optional)