Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Godfried T. Toussaint et. al. "The distance geometry of music" Journal of Computational Geometry: Theory and Applications Volume 42, Issue 5, July, 2009 (http://dx.doi.org/10.1016/j.comgeo.2008.04.005)
Synopsis
- type BJORKLUND_ST a = ((Int, Int), ([[a]], [[a]]))
- bjorklund_left_f :: BJORKLUND_ST a -> BJORKLUND_ST a
- bjorklund_right_f :: BJORKLUND_ST a -> BJORKLUND_ST a
- bjorklund_f :: BJORKLUND_ST a -> BJORKLUND_ST a
- bjorklund :: (Int, Int) -> [Bool]
- bjorklund_r :: Int -> (Int, Int) -> [Bool]
- euler_pp_f :: (Bool -> Char) -> (Int, Int) -> String
- euler_pp_unicode :: (Int, Int) -> String
- euler_pp_ascii :: (Int, Int) -> String
- xdot_ascii :: Bool -> Char
- xdot_unicode :: Bool -> Char
- iseq :: [Bool] -> [Int]
- iseq_str :: [Bool] -> String
Documentation
type BJORKLUND_ST a = ((Int, Int), ([[a]], [[a]])) Source #
Bjorklund state
bjorklund_left_f :: BJORKLUND_ST a -> BJORKLUND_ST a Source #
Bjorklund left process
bjorklund_right_f :: BJORKLUND_ST a -> BJORKLUND_ST a Source #
Bjorklund right process
bjorklund_f :: BJORKLUND_ST a -> BJORKLUND_ST a Source #
Bjorklund process, left & recur or right & recur or halt.
bjorklund :: (Int, Int) -> [Bool] Source #
Bjorklund's algorithm to construct a binary sequence of n bits with k ones such that the k ones are distributed as evenly as possible among the (n - k) zeroes.
bjorklund (5,9) == [True,False,True,False,True,False,True,False,True] map xdot_ascii (bjorklund (5,9)) == "x.x.x.x.x"
let es = [(2,[3,5]),(3,[4,5,8]),(4,[7,9,12,15]),(5,[6,7,8,9,11,12,13,16]),(6,[7,13]),(7,[8,9,10,12,15,16,17,18]),(8,[17,19]),(9,[14,16,22,23]),(11,[12,24]),(13,[24]),(15,[34])] let es' = concatMap (\(i,j) -> map ((,) i) j) es mapM_ (putStrLn . euler_pp_unicode) es'
> E(2,3) [××·] (12) > E(2,5) [×·×··] (23) > E(3,4) [×××·] (112) > E(3,5) [×·×·×] (221) > E(3,8) [×··×··×·] (332) > E(4,7) [×·×·×·×] (2221) > E(4,9) [×·×·×·×··] (2223) > E(4,12) [×··×··×··×··] (3333) > E(4,15) [×···×···×···×··] (4443) > E(5,6) [×××××·] (11112) > E(5,7) [×·××·××] (21211) > E(5,8) [×·××·××·] (21212) > E(5,9) [×·×·×·×·×] (22221) > E(5,11) [×·×·×·×·×··] (22223) > E(5,12) [×··×·×··×·×·] (32322) > E(5,13) [×··×·×··×·×··] (32323) > E(5,16) [×··×··×··×··×···] (33334) > E(6,7) [××××××·] (111112) > E(6,13) [×·×·×·×·×·×··] (222223) > E(7,8) [×××××××·] (1111112) > E(7,9) [×·×××·×××] (2112111) > E(7,10) [×·××·××·××] (2121211) > E(7,12) [×·××·×·××·×·] (2122122) > E(7,15) [×·×·×·×·×·×·×··] (2222223) > E(7,16) [×··×·×·×··×·×·×·] (3223222) > E(7,17) [×··×·×··×·×··×·×·] (3232322) > E(7,18) [×··×·×··×·×··×·×··] (3232323) > E(8,17) [×·×·×·×·×·×·×·×··] (22222223) > E(8,19) [×··×·×·×··×·×·×··×·] (32232232) > E(9,14) [×·××·××·××·××·] (212121212) > E(9,16) [×·××·×·×·××·×·×·] (212221222) > E(9,22) [×··×·×··×·×··×·×··×·×·] (323232322) > E(9,23) [×··×·×··×·×··×·×··×·×··] (323232323) > E(11,12) [×××××××××××·] (11111111112) > E(11,24) [×··×·×·×·×·×··×·×·×·×·×·] (32222322222) > E(13,24) [×·××·×·×·×·×·××·×·×·×·×·] (2122222122222) > E(15,34) [×··×·×·×·×··×·×·×·×··×·×·×·×··×·×·] (322232223222322)
bjorklund_r :: Int -> (Int, Int) -> [Bool] Source #
map xdot_unicode (bjorklund_r 2 (5,16)) == "··×··×··×··×··×·"
euler_pp_unicode :: (Int, Int) -> String Source #
Unicode form, ie. ×·
.
euler_pp_unicode (7,12) == "E(7,12) [×·××·×·××·×·] (2122122)"
euler_pp_ascii :: (Int, Int) -> String Source #
ASCII form, ie. x.
.
euler_pp_ascii (7,12) == "E(7,12) [x.xx.x.xx.x.] (2122122)"
xdot_ascii :: Bool -> Char Source #
xdot notation for pattern.
map xdot_ascii (bjorklund (5,9)) == "x.x.x.x.x"
xdot_unicode :: Bool -> Char Source #
Unicode variant.
map xdot_unicode (bjorklund (5,12)) == "×··×·×··×·×·" map xdot_unicode (bjorklund (5,16)) == "×··×··×··×··×···"