I would like to use a Switch command with IntegerPartitions[n] of terms with n ranging from 3 to 12 and n chosen at run time. I have:
monodromyTypes = IntegerPartitions[n];
switchCodes = Flatten[Table[{monodromyTypes[], i}, {i, 1,Length[monodromyTypes]}], 1];
Then:
switchCodes={{4}, 1, {3, 1}, 2, {2, 2}, 3, {2, 1, 1}, 4, {1, 1, 1, 1}, 5}
and I would like now to use switchCodes in a Switch statement like:
Switch[monodromy,{4}, 1, {3, 1}, 2, {2, 2}, 3, {2, 1, 1}, 4, {1, 1, 1, 1}, 5]
However I can't simply code Switch[monodromy,switchCodes]. I suspect I need to use Sequence but do not know how and was wondering if someone could help me.
Thanks.
Switch[monodromy, ##] & @@ switchCodes, then? – J. M.'s missing motivation Mar 19 '17 at 11:44Sequenceis thatSwitchhas the attributeHoldRest. Consequently, you would need to useEvaluateto override theHoldRest, i.e.,Switch[monodromy, Evaluate[Sequence @@ switchCodes]]. Also, in your initial definition ofswitchCodes, I believe thatmonodromyTypes[]should readmonodromyTypes[[i]]– Bob Hanlon Mar 19 '17 at 14:39