Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Switch but for strings
ResourceFunction["StringSwitch"][string,form1,value1,form2,value2,…] compares string with each of the patterns formi in turn, evaluates, and returns the valuei corresponding to the first match found. |
Switch on a string, just like you have always wanted to:
In[1]:= |
Out[1]= |
Switch using any valid string pattern:
In[2]:= |
Out[2]= |
Provide a default case:
In[3]:= |
Out[3]= |
The first argument must be a String:
In[4]:= |
Out[4]= |
StringSwitch takes an odd number of arguments:
In[5]:= |
Out[5]= |
This work is licensed under a Creative Commons Attribution 4.0 International License