about summary refs log tree commit diff
path: root/website/sandbox/chord-drill-sergeant/src/Misc.elm
diff options
context:
space:
mode:
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