Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate tuples that satisfy a certain criterion
ResourceFunction["SelectTuples"][list,n,crit] generates a list of n‐tuples of elements from list that satisfy crit. | |
ResourceFunction["SelectTuples"][{list1,list2,…},crit] generates a list of all possible tuples whose ith element is from listi that satisfy crit. | |
ResourceFunction["SelectTuples"][…,crit,m] picks at most the first m tuples that satisfy crit. |
Find out which 2-tuples have a sum that is prime:
In[1]:= |
Out[1]= |
Get the first five such 2-tuples:
In[2]:= |
Out[2]= |
Find the first 15 three-letter palindromic lists:
In[3]:= |
Out[3]= |
Find vectors for which the norm is an integer:
In[4]:= |
Out[4]= |
The main difference between Select and Tuples and SelectTuples is the amount of memory used:
In[5]:= |
Out[5]= |
Compared to the naive implementation:
In[6]:= |
Out[6]= |
The length of the results might be smaller than the argument m:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License