'How to implement an else clause in POSIX bc?
POSIX bc has neither an else clause nor boolean operators. Is there any simple way to do simulate an else clause?
Solution 1:[1]
Use a second if statement. The code
if (expression) {
statement1
} else {
statement2
}
in GNU bc does the same as
if (expression) {
statement1
}
if (expression == 0) {
statement2
}
in POSIX bc.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mike Pierce |
