Read-only forum archive

Procedure with optional parameters

Procedure with optional parameters

Guest · Sat Apr 03, 2021 6:27 pm

Hey everyone!

I'm trying to write a procedure that has optional parameters which are set to fixed values if no value is given, i.e. something like

Code:
proc Test (int n, int m = 10) {
return(n*m);
}

Test(2);
//-> 20

Test(2,5);
//-> 10


However, I couldn't find any straight forward way to do this inside of the documentation. Is there any possibility to do this?

Thanks in advance.

Re: Procedure with optional parameters

hannes · Sun Apr 04, 2021 4:35 pm

https://www.singular.uni-kl.de/Manual/4-2-0/sing_44.htm