hmt-0.20: Haskell Music Theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Permutations.List

Description

List permutation functions.

Synopsis

Documentation

permutations_l :: [a] -> [[a]] Source #

Generate all permutations.

permutations_l [0,3] == [[0,3],[3,0]]
length (permutations_l [1..5]) == P.n_permutations 5

permutations_nk_l :: Eq e => Int -> Int -> [e] -> [[e]] Source #

k-element permutations of a set of n-elements.

permutations_nk_l 3 2 "abc" == ["ab","ac","ba","bc","ca","cb"]

multiset_permutations :: Ord a => [a] -> [[a]] Source #

Generate all distinct permutations of a multi-set.

multiset_permutations [0,1,1] == [[0,1,1],[1,1,0],[1,0,1]]

multiset_permutations_n :: Ord a => [a] -> Int Source #

Calculate number of permutations of a multiset.

let r = P.factorial 11 `div` product (map P.factorial [1,4,4,2])
multiset_permutations_n "MISSISSIPPI" == r
multiset_permutations_n "MISSISSIPPI" == 34650
length (multiset_permutations "MISSISSIPPI") == 34650