Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Give all possible ways to partition a set into blocks, ignoring the order of blocks and order within blocks
ResourceFunction["SetPartitions"][set] returns the list of set partitions of set. | |
ResourceFunction["SetPartitions"][n] returns the list of set partitions of {1,2,…, n}. |
There are five set partitions of a three-element set:
In[1]:= |
Out[1]= |
The number of set partitions of a set with n elements is given by the nth Bell number:
In[2]:= |
Out[2]= |
In[3]:= |
Out[3]= |
Here is a compact way to see the blocks:
In[4]:= |
Out[4]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License