While loop question

While loop question - Mensajes

#1 Publicado: 6/4/2023 18:28:44
Razvan

Razvan

0 me gusta en 2 mensajes.

Grupo: User

Hello everybody,

I'm really new to Smath and i am having an issue with the while loop. How can you write multiple conditions for your while loop. While a>b && b>c && c>d.

Would really appreciate some input.
#2 Publicado: 6/4/2023 19:44:47
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

How can you write multiple conditions ...


If you want to piece wise plot conditional ...
if/otherwise ... as any as you want to condition.
From the directed visit Samples, iterative is bidirectional.
Or multiple conditional Golden ratio
More advanced conditional is generally Bolean... Example attached.
Show something of your Creation.
Cheers ... Jean.

Critical Triplet Demo.sm (16,26 KiB) descargado 1397 vez(es).
#3 Publicado: 7/4/2023 0:10:14
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

85 me gusta en 181 mensajes.

Grupo: User

Greetings!

Wrote

Hello everybody,

I'm really new to Smath and i am having an issue with the while loop. How can you write multiple conditions for your while loop. While a>b && b>c && c>d.

Would really appreciate some input.



In the boolean toolbar, you will notice "AND" and "OR" operators, denoted as ⋀ & ⋁ (respectively).

On that note, to specify more then (1) command under your while loop; utilize the "line(" command.

As such, you can copy and paste the following:
line(a:20,b:5,c:1,d:0,while(((a>b)&(b>c))&(c>d),line(cc+(b:b+5)),a:a+1,d:b*(-1),3,1)),stack(a,b,c,d),6,1)=#


I hope this is of Good Help;
- Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
#4 Publicado: 7/4/2023 2:28:10
Razvan

Razvan

0 me gusta en 2 mensajes.

Grupo: User

Cheers, thanks!
#5 Publicado: 7/4/2023 16:12:52
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

... Bolean composite style.

BoleanComposite.PNG
#6 Publicado: 7/4/2023 16:33:31
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

There are also;

ltlt(), altle(), alelt(), a≤blele(), a≤b≤c

gtgt(), a>b>c
gtge(), a>b≥c
gegt(), a≥b>c
gege(), a≥b≥c

These functions are part of Custom Functions plugin.
Unfortunately, it supports only three arguments.
Despite that, some boolean expressions may shorten drastically.

Regards

line(a:20,b:5,c:1,d:0,while((gtgt(b,a,c))&(c>d),line(cc+(b:b+5)),a:a+1,d:b*(-1),3,1)),stack(a,b,c,d),6,1)=#

2023-04-07_22-30.png
A 1 usuarios les gustó este mensaje
João Felipe Seráfico Melo 8/4/2023 14:45:00
#7 Publicado: 8/4/2023 10:17:59
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: Moderator

I've never thought about it, but I think that maybe I can add set of functions with unlimited arguments (>1), gt(#) ge(#) lt(#) le(#)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
A 2 usuarios les gustó este mensaje
João Felipe Seráfico Melo 8/4/2023 14:45:00, overlord 8/4/2023 16:19:00
#8 Publicado: 8/4/2023 14:08:03
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

... adapt the out maths to your project.

AlgoBolean.PNG
#9 Publicado: 8/4/2023 16:20:10
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

Wrote

maybe I can add set of functions with unlimited arguments


Would unlimited versions be mixed or same boolean expression?
#10 Publicado: 8/4/2023 17:52:11
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

... interesting, however very multiple-specific.

BoleanOtherwise.PNG
#11 Publicado: 8/4/2023 21:22:45
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

Wrote

maybe I can add set of functions with unlimited arguments


Would unlimited versions be mixed or same boolean expression?



In addition to gt(#) ge(#) lt(#) le(#), some notes about a relseq function.

relseq.sm (24,53 KiB) descargado 1351 vez(es).

Best regards.
Alvaro.
A 2 usuarios les gustó este mensaje
Mark R Harris 9/4/2023 0:59:00, sergio 10/4/2023 6:28:00
#12 Publicado: 11/4/2023 6:03:38
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: Moderator

Wrote

Would unlimited versions be mixed or same boolean expression?


that way, it would be same boolean

lt(a,b,c,d,e,f)=a<b<c<d<e<f=(a<b)&(b<c)&(c<d)&(d<e)&(e<f)

Wrote

In addition to gt(#) ge(#) lt(#) le(#), some notes about a relseq function.
relseq.sm (24,53 KiB) descargado 1351 vez(es).



That's a good concept, I think that probaly it's feasible. I'll give it a try.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
A 2 usuarios les gustó este mensaje
João Felipe Seráfico Melo 11/4/2023 8:34:00, Alvaro 11/4/2023 10:04:00
#13 Publicado: 13/4/2023 2:45:33
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

... I'll give it a try.



Hi Davide. Something like this other?

Clipboard01.png

Best regards.
Alvaro.
#14 Publicado: 18/4/2023 7:23:00
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: Moderator

Wrote

Hi Davide. Something like this other?



this maybe?

postfix_00.gif

also, prefix/postfix functions can be made for unlimited arguments.

I've tried something like postfix(F,x,y) but it isn't really user-friendly (e.g. it can't be used on the LHS of an assignment because it overvrites the postfix() function itself)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
A 1 usuarios les gustó este mensaje
Alvaro 18/4/2023 12:22:00
#15 Publicado: 18/4/2023 12:25:44
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

... this maybe? ..



Hi Davide. Great implementation. But I'm thinking in ways to write set union a U b, intersection, function composition like f o g (x) := f(g(x)), logical binary operators like implies, iif and similar stuff.

Best regards.
Alvaro.
  • Nuevos mensajes
  • Sin mensajes nuevos