iota-0.1.0.0
Safe HaskellNone
LanguageGHC2021

Data.List.Combinatrics

Synopsis

Documentation

combinations :: Int -> [a] -> [[a]] Source #

>>> combinations 2 [1..3]
[[1,2],[1,3],[2,3]]

allPairs :: [a] -> [(a, a)] Source #

>>> allPairs [1..4]
[(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)]
>>> allPairs []
[]

choice :: [a] -> [(a, [a])] Source #

>>> choice [1..3]
[(1,[2,3]),(2,[1,3]),(3,[1,2])]

pairPartitions :: Eq a => [a] -> [[(a, a)]] Source #

>>> pairPartitions [1..4]
[[(1,2),(3,4)],[(1,3),(2,4)],[(1,4),(2,3)]]
>>> pairPartitions [1..3]
[[(1,2)],[(1,3)],[(2,3)]]
>>> length (pairPartitions[1..16])
2027025
>>> product[1,3..15]
2027025

allPartitions :: Eq a => [a] -> [[[a]]] Source #

>>> allPartitions [1..3]
[[[1],[2],[3]],[[1],[2,3]],[[1,2],[3]],[[1,3],[2]],[[1,2,3]]]
>>> length (allPartitions [1..12])
4213597