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

Music.Theory.Array.Direction

Description

Directions in an array.

Synopsis

LOC / VEC

type LOC n = (n, n) Source #

(column,row)

type VEC n = (n, n) Source #

(Δcolumn,Δrow), rows descend, ie. down is positive, up is negative.

vector_add :: Num n => VEC n -> VEC n -> VEC n Source #

vector_sub :: Num n => VEC n -> VEC n -> VEC n Source #

vector_sum :: Num n => [VEC n] -> VEC n Source #

apply_vec :: Num n => LOC n -> VEC n -> LOC n Source #

segment_vec :: Integral n => VEC n -> [VEC n] Source #

Segment VEC into a sequence of unit steps.

let r = [[(0,0)],[(0,1)],[(0,1),(-1,0)],[(0,1),(0,1),(0,1),(-1,0),(-1,0)]]
in map segment_vec [(0,0),(0,1),(-1,1),(-2,3)] == r

derive_vec :: Num n => LOC n -> LOC n -> VEC n Source #

unfold_path :: Num n => LOC n -> [VEC n] -> [LOC n] Source #

DIRECTION (non-diagonal)

is_direction :: String -> Bool Source #

Directions are D=down, L=left, R=right, U=up.

direction_char_to_vector_tbl :: Num n => [(DIRECTION_C, VEC n)] Source #

Reads either S|D W|L E|R N|U, reverse lookup gives SWEN. A period indicates (0,0). S=south, W=west, E=east, N=north.

dir_seq_to_cell_seq :: (String, [String]) -> [String] Source #

Direction sequence to cell references.