Safe Haskell | Safe-Inferred |
---|

Functions to make *path diagrams* such as those in Fig. VIII-11
on I.Xenakis *Formalized Music*.

- parts :: [a] -> [([a], a, [a])]
- parts' :: [a] -> [(a, [a])]
- gather :: Ord a => [(a, i)] -> [(a, [i])]
- ln_on :: Ln R -> Ln R -> Bool
- overlap :: Ln R -> Ln R -> Bool
- includes :: Ln R -> Ln R -> Bool
- is_included :: Ln R -> Ln R -> Bool
- pt_fn :: ((a, a) -> b) -> Pt a -> b
- ln_fn :: (Num a, Eq a) => ((Pt a, Pt a) -> b) -> Ln a -> b
- ln_pt_fn :: (Num a, Eq a, Num b, Eq b) => (Pt a -> Pt b) -> Ln a -> Ln b
- to_unit :: R -> [Ln R] -> [Ln R]
- data Orientation a
- = Vertical
- | Horizontal
- | Diagonal a

- orientation :: (Fractional a, Eq a) => Ln a -> Orientation a
- type Shift_Map a = [(Pt a, [Orientation a])]
- mk_shift_map :: [Ln R] -> Shift_Map R
- shift_map_pt :: Shift_Map R -> Pt R -> Pt R
- shift_map_ln :: Shift_Map R -> Ln R -> Ln R
- type Shift_Table a = [(Pt a, Pt a)]
- mk_shift_tbl_m :: (Ln R, Bool) -> Maybe (Shift_Table R)
- mk_shift_tbl :: Collision_Table -> Shift_Table R
- shift_table_ln :: Shift_Table R -> Ln R -> Ln R
- type Collision_Table = [(Ln R, Bool)]
- mk_collision_table :: [Ln R] -> Collision_Table
- collision_table_rewrite :: Collision_Table -> [Ln R]
- type Path_Diagram = [(Int, Int)]
- path_diagram_ln :: Path_Diagram -> [Ln R]
- mk_path_ct :: Path_Diagram -> [Ln R]
- mk_path_sm :: Path_Diagram -> [Ln R]

# Genera

parts :: [a] -> [([a], a, [a])]Source

Set of all *(pre,element,post)* triples of a sequence.

parts "abc" == [("",'a',"bc"),("a",'b',"c"),("ab",'c',"")]

parts' :: [a] -> [(a, [a])]Source

All *(element,remainder)* pairs for a sequence.

parts' "abc" == [('a',"bc"),('b',"ac"),('c',"ab")]

gather :: Ord a => [(a, i)] -> [(a, [i])]Source

Gather elements with equal keys.

gather (zip "abcba" [0..]) == [('a',[0,4]),('b',[1,3]),('c',[2])]

# Geometry

overlap :: Ln R -> Ln R -> BoolSource

Do `Ln`

s overlap in the particular sense of being `ln_parallel`

and at least one endpoint of one line lying on the other.

# Orientation

data Orientation a Source

Enumeration of `Vertical`

, `Horizontal`

and `Diagonal`

.

Eq a => Eq (Orientation a) | |

Show a => Show (Orientation a) |

orientation :: (Fractional a, Eq a) => Ln a -> Orientation aSource

Calculate `Orientation`

of `Ln`

.

orientation (ln' (0,0) (0,1)) == Vertical orientation (ln' (0,0) (1,0)) == Horizontal orientation (ln' (0,0) (1,1)) == Diagonal 1

# Shift Map

type Shift_Map a = [(Pt a, [Orientation a])]Source

A table `Pt`

and `Orientation`

set pairs.

# Shift table

type Shift_Table a = [(Pt a, Pt a)]Source

A table of `Pt`

pairs.

mk_shift_tbl_m :: (Ln R, Bool) -> Maybe (Shift_Table R)Source

Make element of `Shift_Table`

.

mk_shift_tbl :: Collision_Table -> Shift_Table RSource

Make complete `Shift_Table`

.

shift_table_ln :: Shift_Table R -> Ln R -> Ln RSource

Apply `Shift_Table`

to `Ln`

.

# Collision table

mk_collision_table :: [Ln R] -> Collision_TableSource

Construct `Collision_Table`

for a set of `Ln`

.

collision_table_rewrite :: Collision_Table -> [Ln R]Source

Construct `Shift_Table`

from `Collision_Table`

and shift all `Ln`

.

# Path diagram

type Path_Diagram = [(Int, Int)]Source

A diagram given as a set of `Int`

pairs.

path_diagram_ln :: Path_Diagram -> [Ln R]Source

Construct set of `Ln`

from `Path_Diagram`

.

mk_path_ct :: Path_Diagram -> [Ln R]Source

`Collision_Table`

based resolution of `Path_Diagram`

.

mk_path_sm :: Path_Diagram -> [Ln R]Source

`Shift_Map`

variant of `mk_path_ct`

.