  Rank: Advanced Member Groups: Registered
Joined: 21/10/2016(UTC) Posts: 82
Was thanked: 21 time(s) in 17 post(s)
|
Hi! Is this a bug in if()? It turns to a real problem e.g. when used in a case like shown in the example.  bug_if.sm (16kb) downloaded 11 time(s).
|
|
|
|
  Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 990  Was thanked: 412 time(s) in 276 post(s)
|
Originally Posted by: MarB  Hi!
Is this a bug in if()?
It turns to a real problem e.g. when used in a case like shown in the example Yes, it is a bug. if() function doesn't like plotting, solvers, custom functions as in your example, etc. You have to use cases() for that kind of usages. Regards
|
|
|
|
  Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,553   Location: Italy Was thanked: 1279 time(s) in 841 post(s)
|
Just to clarify, this is not a fault in the specific function, it works this way because the current architecture of the core doesn't allows a different implementation (thus can't be simply fixed with a change in the function itself).
if(...) currently requires the condition argument to be defined on evaluation, otherwise an error is thrown; this makes the if/else instructions sealed from further evaluations of the preprocessor.
As opposite cases(...) doesn't throw errors on simbolic conditions, but this makes instructions evaluable (thus you shouldn't add any definition in the case() arguments).
|
If you like my plugins please consider a donation to SMath Studio; for personal contributions to me: paypal.me/dcprojects |
 1 user thanked Davide Carpi for this useful post.
|
|
|
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.