hmt-0.16: Haskell Music Theory

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/

Synopsis

# Documentation

data Change Source #

A change either swaps all adjacent bells, or holds a subset of bells.

Constructors

 Swap_All Hold [Int]

Instances

 Source # Methods(==) :: Change -> Change -> Bool #(/=) :: Change -> Change -> Bool # Source # MethodsshowsPrec :: Int -> Change -> ShowS #showList :: [Change] -> ShowS #

data Method Source #

A method is a sequence of changes, if symmetrical only have the changes are given and the lead end.

Constructors

 Method [Change] (Maybe Change)

Instances

 Source # Methods(==) :: Method -> Method -> Bool #(/=) :: Method -> Method -> Bool # Source # MethodsshowsPrec :: Int -> Method -> ShowS #showList :: [Method] -> ShowS #

Compete list of Changes at Method, writing out symmetries.

Parse a change notation.

map parse_change ["-","x","38"] == [Swap_All,Swap_All,Hold [3,8]]

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 from the sequence of changes with possible lead end.

parse_method ("-38-14-1258-36-14-58-16-78",Just "12")

swap_pair :: (s, t) -> (t, s) Source #

Swap elemets of two-tuple (pair).

swap_pair (1,2) == (2,1)

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]

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_change :: Int -> Change -> [a] -> [a] Source #

Apply a Change.

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

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.

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

https://rsw.me.uk/blueline/methods/view/Hammersmith_Bob_Triples

length (closed_method hammersmith_bob_triples [1..7]) == 6

https://rsw.me.uk/blueline/methods/view/Cambridge_Surprise_Major

length (closed_method cambridge_surprise_major [1..8]) == 7

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)

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)