Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Randomly divide a list into a specified number of segments
ResourceFunction["RandomSplit"][list,n] randomly cuts list into n segments. | |
ResourceFunction["RandomSplit"][n] represents an operator form of ResourceFunction["RandomSplit"] that can be applied to an expression. |
Randomly cut a list of length 10 into five segments:
| In[1]:= |
| Out[1]= |
Use another random cut:
| In[2]:= |
| Out[2]= |
Use the operator form:
| In[3]:= |
| In[4]:= |
| Out[4]= |
The operator form is still random in each call:
| In[5]:= |
| Out[5]= |
If the number of segments exceeds the total length of the list, a message is issued:
| In[6]:= |
This work is licensed under a Creative Commons Attribution 4.0 International License