I know the question is rather vague so, here is what I am trying to do:
Lets say we have the following function: `color[data_,variableInputs_]. Now what I want this function to do is loop over the data based on what the input variables are. Suppose, I have the following possible input variables:
"red"
"blue"
"green"
"orange"
Each input variable corresponds to a particular row in the data that I would like to loop over. Thus I want to write a function that will loop over which ever variable I pass into the function, where:
"red" -> data[[i,1]]
"blue" -> data[[i,2]]
"green" -> data[[i,3]]
"orange" -> data[[i,4]]
Without writing out a horrible nested If
functions for all the various permutations of what the inputs may be. So if someone writes:
output = color[data,{"green","orange"}]
I would want the function to look like:
color[dataInput_,variableInputs_]:=(
Table[{dataInput_[[i,3]],dataInput_[[i,4]]},{i,Length@dataInput}]
)
Or if
output = color[data,{"blue"}]
then I would just have
color[dataInput_,variableInputs_]:=(
Table[{dataInput_[[i,2]]},{i,Length@dataInput}]
)
In principal I'm looking for a way to write in mathematica
color[dataInput_,variableInputs_]:=(
Table[{"option_red","option_blue","option_green","option_orange"},{i,Length@dataInput}]
)
where the option are whatever combination of inputs one can put in, without making use of nested If
statements to account for each permutation of inputs. The order of inputs need not matter.
I hope I have explained this clearly enough.