Safe Haskell | None |
---|---|
Language | Haskell98 |
Music.Theory.Permutations.Morris_1984
Contents
Description
Place notation (method ringing).
Morris, R. G. T. "Place Notation" Central Council of Church Bell Ringers (1984). http://www.cccbr.org.uk/bibliography/
- data Change
- data Method = Method [Change] (Maybe Change)
- method_changes :: Method -> [Change]
- parse_change :: String -> Change
- split_changes :: String -> [String]
- parse_method :: (String, Maybe String) -> Method
- is_swap_all :: String -> Bool
- swap_pair :: (s, t) -> (t, s)
- flatten_pairs :: [(a, a)] -> [a]
- swap_all :: [a] -> [a]
- numeric_spelling_tbl :: [(Char, Int)]
- to_abbrev :: String -> [Int]
- gen_swaps :: (Num t, Ord t) => t -> [t] -> [Either t (t, t)]
- derive_holds :: (Eq a, Enum n, Num n) => ([a], [a]) -> [n]
- pair_to_list :: (t, t) -> [t]
- swaps_to_cycles :: [Either t (t, t)] -> [[t]]
- to_zero_indexed :: Enum t => [[t]] -> [[t]]
- swap_abbrev :: Int -> [Int] -> [a] -> [a]
- apply_change :: Int -> Change -> [a] -> [a]
- apply_method :: Method -> [a] -> ([a], [[a]])
- closed_method :: Eq a => Method -> [a] -> [[[a]]]
- closed_method' :: Eq a => Method -> [a] -> [[a]]
- cambridgeshire_slow_course_doubles :: Method
- double_cambridge_cyclic_bob_minor :: Method
- hammersmith_bob_triples :: Method
- cambridge_surprise_major :: Method
- smithsonian_surprise_royal :: Method
- ecumenical_surprise_maximus :: Method
Documentation
A change either swaps all adjacent bells, or holds a subset of bells.
A method is a sequence of changes, if symmetrical only have the changes are given and the lead end.
method_changes :: Method -> [Change] Source #
parse_change :: String -> Change Source #
Parse a change notation.
map parse_change ["-","x","38"] == [Swap_All,Swap_All,Hold [3,8]]
split_changes :: String -> [String] Source #
Separate changes.
split_changes "-38-14-1258-36-14-58-16-78" split_changes "345.145.5.1.345" == ["345","145","5","1","345"]
parse_method :: (String, Maybe String) -> Method Source #
Parse Method
from the sequence of changes with possible lead end.
parse_method ("-38-14-1258-36-14-58-16-78",Just "12")
is_swap_all :: String -> Bool Source #
flatten_pairs :: [(a, a)] -> [a] Source #
Flatten list of pairs.
flatten_pairs [(1,2),(3,4)] == [1..4]
swap_all :: [a] -> [a] Source #
Swap all adjacent pairs at list.
swap_all [1 .. 8] == [2,1,4,3,6,5,8,7]
numeric_spelling_tbl :: [(Char, Int)] Source #
to_abbrev :: String -> [Int] Source #
Parse abbreviated Hold
notation, characters are hexedecimal.
to_abbrev "380ETA" == [3,8,10,11,12,13]
gen_swaps :: (Num t, Ord t) => t -> [t] -> [Either t (t, t)] Source #
Given a Hold
notation, generate permutation cycles.
let r = [Right (1,2),Left 3,Right (4,5),Right (6,7),Left 8] in gen_swaps 8 [3,8] == r
let r = [Left 1,Left 2,Right (3,4),Right (5,6),Right (7,8)] gen_swaps 8 [1,2] == r
derive_holds :: (Eq a, Enum n, Num n) => ([a], [a]) -> [n] Source #
Given two sequences, derive the one-indexed "hold" list.
derive_holds ("12345","13254") == [1]
pair_to_list :: (t, t) -> [t] Source #
Two-tuple to two element list.
swaps_to_cycles :: [Either t (t, t)] -> [[t]] Source #
Swap notation to plain permutation cycles notation.
let n = [Left 1,Left 2,Right (3,4),Right (5,6),Right (7,8)] in swaps_to_cycles n == [[1],[2],[3,4],[5,6],[7,8]]
to_zero_indexed :: Enum t => [[t]] -> [[t]] Source #
One-indexed permutation cycles to zero-indexed.
let r = [[0],[1],[2,3],[4,5],[6,7]] in to_zero_indexed [[1],[2],[3,4],[5,6],[7,8]] == r
swap_abbrev :: Int -> [Int] -> [a] -> [a] Source #
Apply abbreviated Hold
notation, given cardinality.
swap_abbrev 8 [3,8] [2,1,4,3,6,5,8,7] == [1,2,4,6,3,8,5,7]
apply_method :: Method -> [a] -> ([a], [[a]]) Source #
Apply a Method
, gives next starting sequence and the course of
the method.
let r = ([1,2,4,5,3] ,[[1,2,3,4,5],[2,1,3,4,5],[2,3,1,4,5],[3,2,4,1,5],[3,4,2,5,1] ,[4,3,2,5,1],[4,2,3,1,5],[2,4,1,3,5],[2,1,4,3,5],[1,2,4,3,5]]) in apply_method cambridgeshire_slow_course_doubles [1..5] == r
closed_method :: Eq a => Method -> [a] -> [[[a]]] Source #
Iteratively apply a Method
until it closes (ie. arrives back at
the starting sequence).
length (closed_method cambridgeshire_slow_course_doubles [1..5]) == 3
closed_method' :: Eq a => Method -> [a] -> [[a]] Source #
concat
of closed_method
with initial sequence appended.
Methods
cambridgeshire_slow_course_doubles :: Method Source #
https://rsw.me.uk/blueline/methods/view/Cambridgeshire_Slow_Course_Doubles
length (closed_method cambridgeshire_slow_course_doubles [1..5]) == 3
double_cambridge_cyclic_bob_minor :: Method Source #
Double Cambridge Cyclic Bob Minor.
https://rsw.me.uk/blueline/methods/view/Double_Cambridge_Cyclic_Bob_Minor
length (closed_method double_cambridge_cyclic_bob_minor [1..6]) == 5
hammersmith_bob_triples :: Method Source #
Hammersmith Bob Triples
https://rsw.me.uk/blueline/methods/view/Hammersmith_Bob_Triples
length (closed_method hammersmith_bob_triples [1..7]) == 6
cambridge_surprise_major :: Method Source #
https://rsw.me.uk/blueline/methods/view/Cambridge_Surprise_Major
length (closed_method cambridge_surprise_major [1..8]) == 7
smithsonian_surprise_royal :: Method Source #
https://rsw.me.uk/blueline/methods/view/Smithsonian_Surprise_Royal
let m = closed_method smithsonian_surprise_royal [1..10] (length m,nub (map length m),sum (map length m)) == (9,[40],360)
ecumenical_surprise_maximus :: Method Source #
https://rsw.me.uk/blueline/methods/view/Ecumenical_Surprise_Maximus
let m = closed_method ecumenical_surprise_maximus [1..12] (length m,nub (map length m),sum (map length m)) == (11,[48],528)