Feedbacks are more than welcome!
Looks good to me, although I’m a bit far from music
Regarding the code, part below is not very effective:
let build (tonic : note) (scale : Pitch list) =
scale
|> List.fold (fun notes pitch -> notes @ [ pitch (List.last notes) ])
[ tonic ]
Here, you call List.last
for notes
every time and use operator @
for lists one of them contains only single item.
Instead, you could add a new note via operator ::
and then use List.rev
to return result in right order:
let build (tonic : note) (scale : Pitch list) =
scale
|> List.fold (fun notes pitch -> pitch notes.Head :: notes) [ tonic ]
|> List.rev
Btw, there is F# music library already:
1 Like
Awesome, thanks for sharing.