Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline alberich  
#1 Posted : 16 November 2013 10:40:08(UTC)
alberich

Rank: Newbie

Groups: Registered
Joined: 16/11/2013(UTC)
Posts: 2
Germany
Location: Munich

Hello,

I am new to smath and may probably have missed something relating to the syntax.
However, the following result surprised me and I am quite curious why I get this result.
remark: I use smath under linux (debian).

al
alberich attached the following image(s):
for loop.jpg

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline mkraska  
#2 Posted : 16 November 2013 12:34:04(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: alberich Go to Quoted Post
Hello,

I am new to smath and may probably have missed something relating to the syntax.
However, the following result surprised me and I am quite curious why I get this result.
remark: I use smath under linux (debian).

al

Interesting question. I never used lists (systems) to make instruction blocks. As your example demonstrates, the entries in a list (as well as in matrices) are evaluated in reverse sequence.

In the first loop iteration, z is not defined and stored symbolically in b[1;1, then z is set to 1
After leaving the loop, z has the value 9, which is substituted for z when you evaluate b. You see that if you hover with the mouse over the loop statement.

If you reverse the entries, you get the expected behaviour.

Normally you are supposed to use the line() function for instruction blocks. The elements are evaluated top-down and the block has the result of the last statement as return value.

EDIT:

It seems that there are severe operator spacing problems under linux. Between variable and array index there should be more space in order to distinguish such indices from text indices. Also, the := in the loop header look like = because the : is printed over the preceeding operator. You might experiment with the dpi settings.

Edited by user 16 November 2013 12:42:16(UTC)  | Reason: Not specified

File Attachment(s):
line.sm (8kb) downloaded 152 time(s).
mkraska attached the following image(s):
line.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline alberich  
#3 Posted : 17 November 2013 10:36:31(UTC)
alberich

Rank: Newbie

Groups: Registered
Joined: 16/11/2013(UTC)
Posts: 2
Germany
Location: Munich

Thank you for the quick reply.
al
Users browsing this topic
Guest
Similar Topics
Matrix within a matrix not working inside for loop? (Questions)
by wb.c 05/12/2023 10:35:23(UTC)
"Cases" function and for loop (Questions)
by gth802s 21/11/2023 06:06:52(UTC)
Indexing in for loop (Questions)
by Oichi 16/08/2023 17:24:25(UTC)
IF / ELSE within for loop (Questions)
by ianlh 01/12/2021 20:29:34(UTC)
For loop - 1 seat every 30 people (Questions)
by talpacolore 11/10/2021 22:34:23(UTC)
for loop programing issues (Questions)
by wty3000 10/09/2021 08:02:33(UTC)
How to input a group of matrix use for loop (Questions)
by hrwang 29/04/2021 07:34:21(UTC)
Using while loop rather than for loop (Questions)
by hanskl 25/03/2021 12:21:23(UTC)
solver, function with "for loop" not working (Questions)
by rodp1 25/01/2021 05:37:07(UTC)
for loop auto-increment (Bugs & Problems)
by Jean Giraud 12/11/2020 19:18:19(UTC)
Function and for loop (Questions)
by hanskl 05/11/2019 18:52:13(UTC)
How works for loop ? (Questions)
by inazuma 19/04/2019 16:09:59(UTC)
programming if statement in for loop (Questions)
by jbv 12/04/2019 16:55:29(UTC)
test "if statement" in "for loop" (Samples)
by jbv 12/04/2019 15:32:57(UTC)
For Loop - first iteration(s) not correct? (Questions)
by justhumm 26/01/2019 22:37:00(UTC)
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.