# Mathematica How to use Switch with variable number of terms?

1. Mar 18, 2017

### aheight

Hi,

I'd like to use Switch with an integer partition of a number. For example, if n=4, then I define the partition as:
monodromyTypes = IntegerPartitions[n];
this gives:
monodromyTypes={{4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}}. I'd then like to set up a Switch depending on what the monodromy is so I set up the Switch codes as:

switchCodes =
Flatten[Table[{monodromyTypes[[i]], i}, {i, 1,
Length[monodromyTypes]}], 1]

this gives me:

{{4}, 1, {3, 1}, 2, {2, 2}, 3, {2, 1, 1}, 4, {1, 1, 1, 1}, 5}

However just passing that array to Switch won't work. I have to sequence it or something else but I don't know how to format it so it would work with Switch.

I was wondering if someone could help me with this? For example, if monodromy={2,2}, then I want to format Switch as:

Switch[monodromy,{4}, 1, {3, 1}, 2, {2, 2}, 3, {2, 1, 1}, 4, {1, 1, 1, 1},5]

and this would return 3.

Thanks.[/I]

2. Mar 23, 2017

### PF_Help_Bot

Thanks for the thread! This is an automated courtesy bump. Sorry you aren't generating responses at the moment. Do you have any further information, come to any new conclusions or is it possible to reword the post? The more details the better.