programming if statement in for loop

programming if statement in for loop - 消息

#1 已发布: 2019/4/12 10:55:29
jbv74

jbv74

0个赞,共3个帖子。

组: User

Hello everybody
I continue to learn programming in Smath (with no skill in other codes)and have few questions with use of "loops" in the attached file
Hope someone can help a newbie
Thanks
test if in for loop2.sm (23.59 KiB)已下载 1220 次。
#2 已发布: 2019/4/12 11:20:47
Arie

Arie

94个赞,共285个帖子。

组: User

Your function definitions don't include the arguments x and y that you're calling out on the left hand side.

See attached.

test if in for loop2-2_alyles.sm (24.59 KiB)已下载 1236 次。

PS: the reason the first loop even worked, was because when you initially defined F(x,y) A[i and B[i were undefined. Therefore whenever you called F(x,y) in the first loop, it would return the variable A[i and B[i. You were defining A, B and i in each iteration of the loop before calling F(A]i, B]i). So the function appeared to work. However, it didn't matter what values you actually passed to the function. You could have called F(10000000, 2342302034) and you still would have returned the present values of A[i + B[i.

When you defined F(x,y) the second time, A, B, and i were already defined. A=[2;4;7], B=[4;12;21] and i=3. Therefore the value of F(x,y) for any x and y was evaluated to 28. (7+21).
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#3 已发布: 2019/4/12 11:53:49
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Visit these two typical Bolean documents ...
Generally Bolean must be complete [<=, >=].
Otherwise Smath may forgive, but mostly will not forgive.
Among all Bolean, I encountered only one case that <= fails
as the scalar meaning must be vague ... thus <

2D Plot Discontinuous [min(,)].sm (14.19 KiB)已下载 1014 次。
Integrate Discontinuous [Nuance].sm (24.74 KiB)已下载 998 次。
  • 有新帖
  • 无新帖