Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Combination functions.
Synopsis
- nk_combinations :: Integral a => a -> a -> a
- combinations :: Int -> [a] -> [[a]]
- dyck_words_lex :: (Num t, Ord t) => t -> [[t]]
- dyck_word_to_str :: Integral n => [n] -> [Char]
- dyck_word_from_str :: Integral n => [Char] -> [n]
- is_lattice_segment :: Integral n => [n] -> Bool
- is_lattice_word :: Integral n => [n] -> Bool
- is_yamanouchi_word :: Integral n => [n] -> Bool
- is_dyck_word :: String -> Bool
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_yamanouchi_word :: Integral n => [n] -> Bool Source #
is_dyck_word :: String -> Bool Source #
is_lattice_word
of dyck_word_from_str
is_dyck_word "[][[][[[][]]]]" == True