Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import Data.List
  2.  
  3. abc = ["C", "C#/Db", "D", "D#/Eb", "E", "F", "F#/Gb", "G", "G#/Ab", "A", "A#/Bb", "B"]
  4.  
  5. transpose' :: [[Char]] -> [Char] -> Maybe [[Char]]
  6. transpose' scale = fmap (\x -> concat [(drop x scale), (take x scale)]).(`elemIndex` scale)
  7.  
  8. major :: [Char] -> Maybe [[Char]]
  9. major key = let rslt = transpose' abc key in
  10. case rslt of
  11. Just lst -> Just [s | s <- lst, idx <- [0, 2, 4, 5, 7, 9, 11], Just idx == elemIndex s lst]
  12. Nothing -> Nothing
  13.  
  14. foo :: Int -> [Char] -> Maybe [[Char]]
  15. foo shift = (>>= major).fmap (!!shift).major
  16.  
  17. ionic = foo 0
  18. dorian = foo 1
  19. frigian = foo 2
  20. lidian = foo 3
  21. mixolidian = foo 4
  22. eolian = foo 5
  23. locrian = foo 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement