Safe Haskell | None |
---|---|
Language | Haskell2010 |
Set partitions.
- newtype SetPartition = SetPartition [[Int]]
- _standardizeSetPartition :: [[Int]] -> [[Int]]
- fromSetPartition :: SetPartition -> [[Int]]
- toSetPartitionUnsafe :: [[Int]] -> SetPartition
- toSetPartition :: [[Int]] -> SetPartition
- _isSetPartition :: [[Int]] -> Bool
- setPartitions :: Int -> [SetPartition]
- setPartitionsWithKParts :: Int -> Int -> [SetPartition]
- setPartitionsNaive :: Int -> [SetPartition]
- setPartitionsWithKPartsNaive :: Int -> Int -> [SetPartition]
- countSetPartitions :: Int -> Integer
- countSetPartitionsWithKParts :: Int -> Int -> Integer
The type of set partitions
_standardizeSetPartition :: [[Int]] -> [[Int]] Source
fromSetPartition :: SetPartition -> [[Int]] Source
toSetPartitionUnsafe :: [[Int]] -> SetPartition Source
toSetPartition :: [[Int]] -> SetPartition Source
_isSetPartition :: [[Int]] -> Bool Source
Generating set partitions
setPartitions :: Int -> [SetPartition] Source
Synonym for setPartitionsNaive
setPartitionsWithKParts Source
:: Int |
|
-> Int |
|
-> [SetPartition] |
Synonym for setPartitionsWithKPartsNaive
sort (setPartitionsWithKParts k n) == sort [ p | p <- setPartitions n , numberOfParts p == k ]
setPartitionsNaive :: Int -> [SetPartition] Source
List all set partitions of [1..n]
, naive algorithm
setPartitionsWithKPartsNaive Source
:: Int |
|
-> Int |
|
-> [SetPartition] |
Set partitions of the set [1..n]
into k
parts
countSetPartitions :: Int -> Integer Source
Set partitions are counted by the Bell numbers
countSetPartitionsWithKParts Source
Set partitions of size k
are counted by the Stirling numbers of second kind