Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
Offline jbv  
#1 Posted : 12 April 2019 16:55:29(UTC)

Rank: Newbie

Groups: Registered
Joined: 17/03/2019(UTC)
Posts: 3

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
test if in for loop2.sm (24kb) downloaded 13 time(s).
Offline alyles  
#2 Posted : 12 April 2019 17:20:47(UTC)

Rank: Advanced Member

Groups: Registered
Joined: 23/03/2016(UTC)
Posts: 169
United States

Was thanked: 52 time(s) in 36 post(s)
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 (25kb) downloaded 15 time(s).

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).

Edited by user 12 April 2019 17:45:38(UTC)  | Reason: Not specified

Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
Offline Jean Giraud  
#3 Posted : 12 April 2019 17:53:49(UTC)
Jean Giraud

Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 3,661

Was thanked: 682 time(s) in 532 post(s)
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 (15kb) downloaded 15 time(s).
Integrate Discontinuous [Nuance].sm (25kb) downloaded 12 time(s).
Users browsing this topic
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.