The 'if' logic appears to be backwards

The 'if' logic appears to be backwards - Сообщения

#1 Опубликовано: 13.09.2009 04:02:39
mar

mar

0 сообщений из 13 понравились пользователям.

Группа: User

x:=0
if x=0
y:=0
else
y:=1

y=1 (should be 0)


x:=1
(same conditional above)
y=0 (should be 1)
#2 Опубликовано: 13.09.2009 07:24:08
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello mar,
[LIVE width=170 height=282]http://smath.info/live/?file=631[/LIVE]
You must have done something wrong. It seems Ok.

Regards,
radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Опубликовано: 13.09.2009 11:42:14
mar

mar

0 сообщений из 13 понравились пользователям.

Группа: User

I just re-tested using both my example & your example and I still get the wrong answer for both. I have ver 0.85 build 3531 installed under winXP SP3.

I also tried to test under the live web version but could not figure out how to add the 'if' conditional since the selection list over on the right does not seem to contain the conditional functions like the installed version.

By the way how are you getting smath pages pasted into the forum?

Update:
Ok it looks like I have issolated my problem. When I entered the conditional in the 'if' stmt I used the stnd '=' key instead of the actual boolean test condition '=' from the right side panel. They both look the same other than the fact that the boolean version appears in bold type. Any reason why smath did not automatically take and convert my stnd '=' into into a boolean test conditional '=' given the context in which it was entered?
#4 Опубликовано: 13.09.2009 12:15:22
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello mar,
Wrote

I just re-tested using both my example & your example and I still get the wrong answer for both. I have ver 0.85 build 3531 installed under winXP SP3.

Could you send the *.sm file to me, and will see. My email is omorr@uns.ac.rs
Wrote


I also tried to test under the live web version but could not figure out how to add the 'if' conditional since the selection list over on the right does not seem to contain the conditional functions like the installed version.


There are some restrictions about "Live" version. You can make a *.sm file on your computer and choose the "Upload" option in "Live" SMath from the lower right corner (easyer and faster). After the file has been uploaded, you can get the LIVE link - lower right corner. This link put (copy/paste) into your post and you will get the same as I did.
Wrote


By the way how are you getting smath pages pasted into the forum?


Yuo can have pictures and files into this forum, but you have to provide the links for them. Try to "Quote" some of the posts and see the way. You can upload the files on some free upload file services and provide the adress for them "http://...". There is also an upload SMath server but it is in Russian only (not translated to English yet).

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#5 Опубликовано: 13.09.2009 12:21:28
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello mar,
Wrote

Update:
Ok it looks like I have issolated my problem. When I entered the conditional in the 'if' stmt I used the stnd '=' key instead of the actual boolean test condition '=' from the right side panel. They both look the same other than the fact that the boolean version appears in bold type. Any reason why smath did not automatically take and convert my stnd '=' into into a boolean test conditional '=' given the context in which it was entered?


It is a common mistake. I do not believe it could be possible to convert stnd '=' into a boolean test conditional '=' (shortcut is CTRL+=). You have to take care of this.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#6 Опубликовано: 13.09.2009 12:40:27
mar

mar

0 сообщений из 13 понравились пользователям.

Группа: User

If smath can not auto translate the stnd '=' into a valid boolean test cond '=' than maybe it could flag the fact that the entire conditional arg does not contain a vaild boolean test condition?
#7 Опубликовано: 13.09.2009 12:45:16
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Wrote

If smath can not auto translate the stnd '=' into a valid boolean test cond '=' than maybe it could flag the fact that the entire conditional arg does not contain a vaild boolean test condition?


Yes, you might be right. I am sure that the SMath author Andrey will answer this.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#8 Опубликовано: 13.09.2009 20:16:25
Andrey Ivashov

Andrey Ivashov

2269 сообщений из 3730 понравились пользователям.

Группа: Super Administrator

mar, this is impossible to implement auto conversion of the 'equal to' operator. Unfortunately.
But, please, tell me, how you could write not boolean 'equal to' into the condition of if function? I can't find the way.

omorr, thank you!
#9 Опубликовано: 14.09.2009 06:06:31
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Wrote

mar, this is impossible to implement auto conversion of the 'equal to' operator. Unfortunately.
But, please, tell me, how you could write not boolean 'equal to' into the condition of if function? I can't find the way.

omorr, thank you!


You are welcome,

I'll comment this, if you do not mind. Actually, it is possible. The error will be issued

but you can continue. After the first expression below if, the equal sign will shift to the right

and finally


Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#10 Опубликовано: 14.09.2009 08:33:24
Greg Locock

Greg Locock

0 сообщений из 53 понравились пользователям.

Группа: User

A change in syntax might be to use == for boolean test =, while keeping := for assignment=

I'm surprised it can't figure out which is meant from context after an 'if' keyword
#11 Опубликовано: 14.09.2009 11:55:36
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello Greg,

I think this is a bug - kind of. Actually, "if" is the only tool from Programming palette which will return a value (I think). For instance (Pay attention on equal to signs)
[MATH]if(1≡1;5;6)=5[/MATH]
or
[MATH]if(1≡0;5;6)=6[/MATH]
or
[MATH]x←0[/MATH]
[MATH]a←if(x≡0;10;20)[/MATH]
[MATH]a=10[/MATH]

There is the way it works. I suppose something goes wrong and should be checked out here.

[MATH]if(x;y←9;z←8)=90[/MATH]

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#12 Опубликовано: 19.01.2017 03:32:52
Evgenij

Evgenij

1 сообщений из 8 понравились пользователям.

Группа: User

By the way
Impossible to assign to a function different values according conditions.
An example in the cloud

Or how it would by correct?
#13 Опубликовано: 19.01.2017 10:50:59
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

By the way
Impossible to assign to a function different values according conditions.
An example in the cloud

Or how it would by correct?



Please: attach your request in a work sheet.

#14 Опубликовано: 19.01.2017 13:00:56
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

An example in the cloud



Can't find the file in cloud.

Generally, conditions must be completely specified [Integrate Discontinuous].
Odd cases happen one of the condition must not be completely specified.
Success or failure is the sole guide. Each case exemplified in the attached.

Jean

Integrate Discontinuous.sm (22 КиБ) скачан 31 раз(а).

Spline De Boor [Colibri].sm (32 КиБ) скачан 29 раз(а).

#15 Опубликовано: 19.01.2017 13:24:01
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Generally, conditions must be completely specified [Integrate Discontinuous].



... This example is constructed on Davide "cases".
The numerical integrator works with "cases".
Numerical integrator does NOT "if/else"
"cases" is needed with 'convolution stuff'

Cheers

Integrate Discontinuous [UN].sm (18 КиБ) скачан 25 раз(а).
#16 Опубликовано: 19.01.2017 14:05:38
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

"cases" is needed with 'convolution stuff'



... here is the convolution "cases" example:

Convolution RC 6179.sm (13 КиБ) скачан 32 раз(а).

  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений