diff options
author | William Carroll <wpcarro@gmail.com> | 2020-04-12T15·43+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-04-12T15·43+0100 |
commit | 24692ab46508d5e3348af19a6eae583a6d02e0e7 (patch) | |
tree | d4b3c36d303957f5d32213bccb83bd291b6c7a04 /website/sandbox/chord-drill-sergeant/src/Misc.elm | |
parent | 730aecc076fd21c48884201f59c9b1fce8c7a23a (diff) |
Properly support chord inversions
While I did change a lot of functionality, I also ran `elm-format` across the codebase, which makes these changes a bit noisy. Here is the TL;DR: - Properly support chord inversions - Ensure that the piano styling changes dynamically when I change the variables like `naturalWidth` - Add start and end notes to define the size of the piano and which chords we create - Support elm-format and run it across entire project - Debug Misc.comesBefore - Introduce a ChordInspector and debugger TODO: Ensure that we only generate chords where all of the notes can be rendered on the displayed keys. TODO: Add preferences panel, so that I can do things like "Practice blues chords in C and E with chord substitutions."
Diffstat (limited to 'website/sandbox/chord-drill-sergeant/src/Misc.elm')
-rw-r--r-- | website/sandbox/chord-drill-sergeant/src/Misc.elm | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/website/sandbox/chord-drill-sergeant/src/Misc.elm b/website/sandbox/chord-drill-sergeant/src/Misc.elm index 479234ff1546..451c5c315c50 100644 --- a/website/sandbox/chord-drill-sergeant/src/Misc.elm +++ b/website/sandbox/chord-drill-sergeant/src/Misc.elm @@ -1,15 +1,35 @@ module Misc exposing (..) + comesAfter : a -> List a -> Maybe a comesAfter x xs = case xs of - [] -> Nothing - _::[] -> Nothing - y::z::rest -> if y == x then Just z else comesAfter x (z::rest) + [] -> + Nothing + + _ :: [] -> + Nothing + + y :: z :: rest -> + if y == x then + Just z + + else + comesAfter x (z :: rest) + comesBefore : a -> List a -> Maybe a comesBefore x xs = case xs of - [] -> Nothing - _::[] -> Nothing - y::z::rest -> if z == x then Just y else comesAfter x (z::rest) + [] -> + Nothing + + _ :: [] -> + Nothing + + y :: z :: rest -> + if z == x then + Just y + + else + comesBefore x (z :: rest) |