Functions that build switch functions.