For ease of use and readability in a program that I’m writing, I would like users to be able to define functions with any combination (and if possible order) of a fixed set of symbols, say {a,b,c,d}
. This function needs to be able to be called in another function that is part of some algorithm. The symbol names have inherent meaning within the algorithm. As an example I might have a function that depends on any of three cartesian coordinates {x,y,z}
of a grid.
I’m not sure how I would deal with the fact that the algorithm doesn’t know how many and which of the arguments the function will take. I know how to extract the argument names as symbols, so in principle I could write a a lot of if statements for all combinations of the arguments, but this obviously a very inelegant and cumbersome option. I might also want to expand the set of allowed symbols later on, so the amount of combinations might get very big…
Another solution would be to always define any of the functions with all of the argument names. This is not great for readability, however, since it would be very nice to see from just the function, on which of the arguments it depends.
Is there a good way to do this, or is this just bad practice?