I am using a function with a lot of variables. There are 9 and sometimes more of them. In this case, it is difficult to memorize, which one stays on the, say, fourth position, and which one - on the seventh. I would like to be able to include the variable name into the square brackets of the function as a reminder: what must stay here.
For example, let us define a simple function: f(x)=x^2+y^3
. Here is its definition:
f[x_,y_]:=x^2+y^3;
One can, however, call it with x=5
and y=7
as follows:
f[(*x=*)5,(*y=*)7]
This way reminds me of what should stay in the first and in the second position inside the square brackets.
This works, but I do not like that it looks cumbersome. For perception, it would be much better, if the (*
and *)
signs are invisible.
Any idea?
f[“x” -> 5, “y” -> 7]
$\endgroup$f[__]:=x^2+y^3; f[x=5,y=3]
seems to be the most economic. Therefore, I choose this one. However, I like all the solutions you proposed, and I will use them from now on. Thank you. $\endgroup$