Feature Request: SWITCH command

Alex shared this idea 4 years ago
Declined

Hi,


I usually use the IF command in nested format, like:


  1. a=If[condition1,value1,If[condition2,value2,If[condition3,value3,If[condition4,value4,value5]]]]

Do we have another command to simplify in this situation? If there are many conditions, it is not easy to read the above command.


Can GeoGebra provide something like the "SWITCH" command in other programming languages?


  1. e.g. a=Switch[condition1, value1, condition2, value2, ..., conditionN, valueN, defaultValue]


I think this can help beginners to take up GeoGebra easier.

Thank you for your consideration.


Cheers,

Alex

Comments (3)

photo
1

You can use If[cond1,val1,cond2,val2,cond3,val3,...].


Also Element[list of values,IndexOf[value, list of cases]] may be useful sometimes.

photo
1

So great!

In this case, I suggest the page https://www.geogebra.org/ma...

should be updated with examples to help users:

e.g. If[a ≟ 1, "Matthew", a ≟ 2, "Larry", a ≟ 3, "Vivian", "Alex"]

Thanks,

Alex

photo
1

Thanks, updated.

photo
© 2021 International GeoGebra Institute