Program loops- one big one or a few smaller ones

Program loops- one big one or a few smaller ones - Сообщения

#1 Опубликовано: 05.11.2018 19:55:09
Dionysios J. Pantazis

Dionysios J. Pantazis

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

Группа: User

Hi all-

I am trying to build good habits as I learn and grow my SMATH skills- I have a calc sheet with 3 programming loops in it. I realized that I have 2 loops side by side to one, and then there are others ordered as a list under those.

In each of them, I j as my step variable- just because that is how I learned for-then loops ages ago. It occurred to me that I might be setting myself up for trouble as I build and expand things.

Is there 'better' way to organize this? How do you break things like loops to be more human readable?

Can you reuse the loop variables like this? Should each loop have its own variable, or should they all use the same one?

EDIT: Here is a screen shot with the regions and loops I am referring to.

Dennis

loop-opti.png
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#2 Опубликовано: 06.11.2018 00:06:24
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

Can you reuse the loop variables like this ?
Shoud each loop have its own variable, or shoud they all use the same one ?



On that, answer is not clear cut. In many instances, Smath behave like Mathcad global definition.
Interesting but source of problem. It does not generally evaporate previous use of variables.
The safe way to debug is modular piece-wise construction. In unexplored limits, the right produces
wrong. Smath is superb for detecting errors as long as it is not too far deep embedded.
On the other hand, bear in mind the QA [Quality Assurance], they work piece-wise.
The attached De Casteljau is a good example of chained style construction.
As well, visit Samples for the latest "Draghilev Revisited".

Jean

Spline De Casteljau SVG Companion.sm (98 КиБ) скачан 38 раз(а).


#3 Опубликовано: 06.11.2018 11:10:19
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

Here is a screen shot with the regions and loops I am referring to.



As it looks Dennis, all that invisible stuff is a collection of individual pieces.

X_Y Plot wisely [Lines].sm (12 КиБ) скачан 43 раз(а).
1 пользователям понравился этот пост
sergio 06.11.2018 12:13:00
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений