Suppose that I want to write a function
fun that takes an
num as input, and returns
num == 1,
num == 2, and
num == 3. One way, I think, to do this is to use
fun[num_Integer] := Which[num == 1, Red, num == 2, Orange, num == 3, Yellow]
Is there a more concise way to write
fun? In other words, is there any built-in function (analogous to
Which) that I can use that would allow me to avoid typing "
num" all the time instead of always having to specify it to
fun as a series of nested
If statements would be even lengthier.
Do you have any suggestions? Thanks for your time.