Cycles shader multiplexer node? Is there some way to select one output from a number of inputs with a Fac, like a Mix shader, but instead of a 0-1 slider, use an integer index (for more than two inputs)?

Example (in Quartz Composer):



If possible, I would like to use an arbitrary number of inputs (e.g. with Python somehow), but I don't know if that is possible.
I found a way to do this that takes a fixed number of inputs (it also has the useful property of mixing its inputs given a non-integer):



This is extensible, but only by manually editing the node group.