Collecting multiple function arguments into a List?
- To: mathgroup at smc.vnet.net
- Subject: [mg30519] Collecting multiple function arguments into a List?
- From: aes <siegman at stanford.edu>
- Date: Fri, 24 Aug 2001 20:58:13 -0400 (EDT)
- Organization: Stanford University
- Sender: owner-wri-mathgroup at wolfram.com
I have a problem with 8 input variables, call 'em x1, x2, ... , x8, and I want to define a bunch of functions (using :=, not =) that depend on various subsets of these variables, e.g. f1[ x1_, x2_, x4_] := << stuff involving x1, x2, x4 >> f2[ x1_, x3_] := << stuff involving x1 and x3 only >> f3[[x2_, x3_, x5_, x8_} := << stuff involving x2, x3, x5, x8 >> To minimize typing and bookkeeping I'd like to define a list of the input variables, e.g. vars = {x1, x2, x3, x4, x5, x6, x7, x8} and then write all the function definitions in the simplified syntax f1[vars_] := << same stuff as above >> f2[vars_] := << same stuff as above >> f3[vars_] := << same stuff as above >> Can I do this? What's the required syntax? vars = {x1, x2, x3 ...} ?? OR vars = {x1_, x2_, x3_} ?? fn[vars] := << >> ?? OR fn[vars_] := << >>?? Thanks, siegman at stanford.edu