diff options
author | William Carroll <wpcarro@gmail.com> | 2020-04-18T12·30+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-04-18T12·30+0100 |
commit | f0803547e47827a3fb3b9fb1f89949fa270b6d8e (patch) | |
tree | 1eb84a865896fafa0c07e8c45396c5d4ffebf3ab /website/sandbox/learnpianochords/src/Misc.elm | |
parent | 39d084e493c80952d59cbcc92ea67f344e543298 (diff) |
"Chord Drill Sergeant" -> "Learn Piano Chords"
In the spirit of "keep it simple, stupid", I am naming this application as closely to the functionality as I can imagine.
Diffstat (limited to 'website/sandbox/learnpianochords/src/Misc.elm')
-rw-r--r-- | website/sandbox/learnpianochords/src/Misc.elm | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/website/sandbox/learnpianochords/src/Misc.elm b/website/sandbox/learnpianochords/src/Misc.elm new file mode 100644 index 000000000000..52f957ad528f --- /dev/null +++ b/website/sandbox/learnpianochords/src/Misc.elm @@ -0,0 +1,47 @@ +module Misc exposing (..) + +import Array exposing (Array) + + +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) + + +comesBefore : a -> List a -> Maybe a +comesBefore x xs = + case xs of + [] -> + Nothing + + _ :: [] -> + Nothing + + y :: z :: rest -> + if z == x then + Just y + + else + comesBefore x (z :: rest) + + +find : (a -> Bool) -> List a -> Maybe a +find pred xs = + case xs |> List.filter pred of + [] -> + Nothing + + x :: _ -> + Just x |