SMath Studio Forum
»
SMath Studio
»
Questions
»
IF ELSE VERSUS CASES FORMALISM
Rank: Advanced Member Groups: Registered
Joined: 03/06/2023(UTC) Posts: 61 Was thanked: 1 time(s) in 1 post(s)
|
Help would be appreciated. I cannot make a chain of if-else statements equal to the cases formalism. What am I missing. I have tried the less than or equal only in the cases formalism. That didn't work either. The if-else results are correct, the cases formalism is not correct. IF ELSE VERSUS CASES FORMALISM.sm (13kb) downloaded 7 time(s).Thanks for any help. Reg |
Reg Curry Loveland, CO
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/06/2023(UTC) Posts: 61 Was thanked: 1 time(s) in 1 post(s)
|
Oops sorry. I had errors in my formulas. Here is the corrected version where the two formalisms do agree. IF ELSE VERSUS CASES FORMALISM.sm (13kb) downloaded 9 time(s).Sorry |
Reg Curry Loveland, CO
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,678 Location: Italy Was thanked: 1364 time(s) in 892 post(s)
|
No problem, when possible, better ask. I would point out that currently you can avoid the nested if/else and convert it in if/else if/else (if you wish), simply adding more arguments. As side note if you delete an argument from the default if/else, you'll get an if without else. IF ELSE VERSUS CASES FORMALISM(2).sm (17kb) downloaded 19 time(s).Also, since the topic is about if/else vs cases, I would like to highlight that cases has a different coding approach to evaluate in some situations where if/else is not allowed to; this feature comes at the cost that you shouldn't make assignments ( : ) inside its arguments, while in if/else you can safely build block of codes inside it using the line function (see here and here for examples). Edited by user 10 May 2024 10:15:37(UTC)
| Reason: small clarification |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/06/2023(UTC) Posts: 61 Was thanked: 1 time(s) in 1 post(s)
|
Davide, Thanks much. Very helpful as always. Reg |
Reg Curry Loveland, CO
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
IF ELSE VERSUS CASES FORMALISM
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.