hmt-0.15: Haskell Music Theory

Safe Haskell | None
Language | Haskell98

Music.Theory.Permutations.Morris_1984

Contents

- Methods

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

- data Change
  - = Swap_All
  - | Hold [Int]
- 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]
- to_abbrev :: String -> [Int]
- gen_swaps :: (Num t, Ord t) => t -> [t] -> [Either t (t, t)]
- pair_to_list :: (t, t) -> [t]
- swaps_to_cycles :: [Either t (t, t)] -> [[t]]
- to_zero_indexed :: Enum t => [[t]] -> [[t]]
- swap_abbrev :: Eq a => Int -> [Int] -> [a] -> [a]
- apply_change :: Eq a => Int -> Change -> [a] -> [a]
- apply_method :: Eq a => 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

# Documentation

data Change Source #

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

Constructors

Swap_All |
Hold [Int] |

Instances

Eq Change Source # |
Methods (==) :: Change -> Change -> Bool # (/=) :: Change -> Change -> Bool #
Show Change Source # |
Methods showsPrec :: Int -> Change -> ShowS # show :: Change -> String # 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

Eq Method Source # |
Methods (==) :: Method -> Method -> Bool # (/=) :: Method -> Method -> Bool #
Show Method Source # |
Methods showsPrec :: Int -> Method -> ShowS # show :: Method -> String # showList :: [Method] -> ShowS #

method_changes :: Method -> [Change] Source #

Compete list of `Change`s at `Method`, writing out symmetries.

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 #

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 "38A" == [3,8,10]

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

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

Apply a `Change`.

apply_method :: Eq a => 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 #

Cambridgeshire Slow Course Doubles.

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 #

Cambridge Surprise Major.

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

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

smithsonian_surprise_royal :: Method Source #

Smithsonian Surprise Royal.

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

    length (closed_method smithsonian_surprise_royal [1..10]) == 9