Next: Conditional Blocks, Previous: if-then, Up: Conditionals and Loops [Contents][Index]
Use the
ie
and
el
requests to write an if-then-else.
The first request is the “if” part
and the latter is the “else” part.
Unusually among programming languages,
any number of non-conditional
requests may be interposed between the
ie
branch and the
el
branch.
.nr a 0
.ie \na a is non-zero.
.nr a +1
.el a was not positive but is now \na.
⇒ a was not positive but is now 1.
Another way in which el is an ordinary request is that it does
not lexically “bind” more tightly to its ie counterpart than it
does to any other request. This fact can surprise C programmers.
.nr a 1
.nr z 0
.ie \nz \
. ie \na a is true
. el a is false
.el z is false
⇒ a is false
To conveniently nest conditionals, keep reading.