- #1
aheight
- 321
- 109
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]
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]