Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a list of all tuples of characters from a string
ResourceFunction["StringTuples"]["string",n] generates a list of all possible length-n strings formed from the characters in "string". | |
ResourceFunction["StringTuples"]["string",{m,n}] generates a list of all possible strings with lengths m through n. | |
ResourceFunction["StringTuples"][{"string1","string2",…}] generates a list of all possible strings whose ith character is from "stringi". |
Generate all length-3 strings containing A and B:
In[1]:= |
Out[1]= |
Generate strings with length 1 through 3:
In[2]:= |
Out[2]= |
All ways of picking a character from each string:
In[3]:= |
Out[3]= |
Duplicated characters are treated as distinct:
In[4]:= |
Out[4]= |
Results from Outer involve extra sublists:
In[5]:= |
Out[5]= |
In[6]:= |
Out[6]= |
This work is licensed under a Creative Commons Attribution 4.0 International License