Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Choose random parts of an expression
ResourceFunction["RandomPartChoice"][expr] chooses a random subexpression from expr. | |
ResourceFunction["RandomPartChoice"][expr,count] chooses count subexpressions. | |
ResourceFunction["RandomPartChoice"][expr,count,levelspec] only considers subexpressions at levels given by levelspec. | |
ResourceFunction["RandomPartChoice"][expr,count,levelspec,wrapper] applies wrapper to each item before returning the result. | |
ResourceFunction["RandomPartChoice"][expr,count,levelspec,wrapper,pattern] only considers subexpressions that match pattern. |
Get a random part of an expression:
| In[1]:= |
| Out[1]= |
Get multiple parts:
| In[2]:= |
| Out[2]= |
Provide a level specification:
| In[3]:= |
| Out[3]= |
Apply a function to each item before returning:
| In[4]:= |
| Out[4]= |
Restrict sampling to elements that match a given pattern:
| In[5]:= |
| Out[5]= |
Use Automatic for the count to obtain the one-argument behavior when providing additional arguments:
| In[6]:= |
| Out[6]= |