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

Music.Theory.Combinations

Contents

Description

Combination functions.

Synopsis

Documentation

nk_combinations :: Integral a => a -> a -> a Source #

Number of k element combinations of a set of n elements.

map (uncurry nk_combinations) [(4,2),(5,3),(6,3),(13,3)] == [6,10,20,286]

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

k element subsets of s.

combinations 3 [1..4] == [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
length (combinations 3 [1..5]) == nk_combinations 5 3
combinations 3 "xyzw" == ["xyz","xyw","xzw","yzw"]

Dyck

dyck_words_lex :: (Num t, Ord t) => t -> [[t]] Source #

http://www.acta.sapientia.ro/acta-info/C1-1/info1-9.pdf (P.110)

dyck_words_lex 3 == [[0,0,0,1,1,1],[0,0,1,0,1,1],[0,0,1,1,0,1],[0,1,0,0,1,1],[0,1,0,1,0,1]]

dyck_word_to_str :: Integral n => [n] -> [Char] Source #

Translate 01 to [].

unwords (map dyck_word_to_str (dyck_words_lex 3)) == "[[[]]] [[][]] [[]][] [][[]] [][][]"

dyck_word_from_str :: Integral n => [Char] -> [n] Source #

Translate [] to 01

is_lattice_segment :: Integral n => [n] -> Bool Source #

Is x a segment of a lattice word.

is_lattice_word :: Integral n => [n] -> Bool Source #

Is x a lattice word.

is_lattice_word [1,1,1,2,2,1,2,1] == True

is_dyck_word :: String -> Bool Source #

is_lattice_word of dyck_word_from_str

is_dyck_word "[][[][[[][]]]]" == True