summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/map-editor/src/Util/List.elm')
-rw-r--r--src/map-editor/src/Util/List.elm16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/map-editor/src/Util/List.elm b/src/map-editor/src/Util/List.elm
new file mode 100644
index 0000000..2bc5217
--- /dev/null
+++ b/src/map-editor/src/Util/List.elm
@@ -0,0 +1,16 @@
+module Util.List exposing (..)
+
+import List
+
+pop : List a -> (Maybe (a, List a))
+pop l =
+ case
+ ((List.head l), (List.tail l))
+ of
+ (Nothing, _) -> Nothing
+ (_ , Nothing) -> Nothing
+ ((Just head), (Just tail)) -> (Just (head, tail))
+
+get_first : (a -> Bool) -> (List a) -> (Maybe a)
+get_first fun list =
+ (List.head (List.filter fun list))