about summary refs log tree commit diff
path: root/website/sandbox/chord-drill-sergeant/src/Misc.elm
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-04-13T14·07+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-04-13T14·46+0100
commita64601cc058950d094a1daa512c94d91d11756cf (patch)
tree1fbe488a6c461668235ef1bf0cece6ac7ad39a2f /website/sandbox/chord-drill-sergeant/src/Misc.elm
parent6a3af6c9c61a8237dfee96c3eb5ce8f9cb2bc0d8 (diff)
Support generating chords for a particular key
Generate chords for a given key.

I believe my Theory.allChords function is taking a long time to generate all of
the chord possibilities. I would like to profile this to verify this
assumption. I think I can create a "staging area" for changes and only
regenerate chords when "committing" the options from the "staging area". This
should stress the application less.

TODO: Profile application to find bottleneck.
Diffstat (limited to 'website/sandbox/chord-drill-sergeant/src/Misc.elm')
-rw-r--r--website/sandbox/chord-drill-sergeant/src/Misc.elm12
1 files changed, 12 insertions, 0 deletions
diff --git a/website/sandbox/chord-drill-sergeant/src/Misc.elm b/website/sandbox/chord-drill-sergeant/src/Misc.elm
index 451c5c315c50..52f957ad528f 100644
--- a/website/sandbox/chord-drill-sergeant/src/Misc.elm
+++ b/website/sandbox/chord-drill-sergeant/src/Misc.elm
@@ -1,5 +1,7 @@
 module Misc exposing (..)
 
+import Array exposing (Array)
+
 
 comesAfter : a -> List a -> Maybe a
 comesAfter x xs =
@@ -33,3 +35,13 @@ comesBefore x xs =
 
             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