fix issue 9942 - Add a functional switch function

std.algorithm.predSwitch is the functional version of the `switch`
statement(without a lookup table).