Passing function arguments as lists of replacement rules
- To: mathgroup at smc.vnet.net
- Subject: [mg104661] Passing function arguments as lists of replacement rules
- From: dnquark <dnquark at gmail.com>
- Date: Fri, 6 Nov 2009 05:16:08 -0500 (EST)
I wish to (a) avoid having to pass a dozen parameters to a function
and have to deal with remembering which goes where and (b) retain the
flexibility in terms of adding new parameters. It seems that a good
solution would be to pass my parameters as a structure with named
fields (this is how I do it in another system). In Mathematica, I came up
with something like this:
foo[paramList_] := Module[{a,b,c},
{a,b,c} = {"a","b","c"}/.paramList;
{a,b,c}
]
sample usage: e.g. foo[{"a"->1,"b"->2}]
My question to the group: is this a good solution? Are there better
ways to achieve my goals?..
Thanks,
--Leo