Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Randomly select a given number of elements from a list or expression
ResourceFunction["RandomSampleOf"][n] randomly selects n elements from the list or expression it is applied to. |
Randomly select five elements from a word list:
In[1]:= |
Out[1]= |
Randomly select ten element from a list of integers:
In[2]:= |
Out[2]= |
RandomSampleOf is effectively an operator version of RandomSample, but with a more concise syntax:
In[3]:= |
Out[3]= |
Wolfram Language 12.3 (May 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License