|
Similar concept but a little simpler and avoids manually written recursion. notes = cycle ["c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"]
majorSteps = [2, 2, 1, 2, 2, 2] :: [Int]
scale note = map (dropWhile (/= note) notes !!) . scanl (+) 0
I think it's less clear, but if you want to avoid the rescan via (!!), then scale note = map head . scanl (flip drop) (dropWhile (/= note) notes)
Both result in λ> scale "d" majorSteps
["d","e","f#","g","a","b","c#"]
|