From 2c9b2af9ac011a871c5c02d3e2258fca73a98880 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 27 Sep 2017 10:31:16 +0200 Subject: Splits client and server into two repositories. --- elm/battlemap/src/Util/Array.elm | 14 ++++++++++++++ elm/battlemap/src/Util/List.elm | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 elm/battlemap/src/Util/Array.elm create mode 100644 elm/battlemap/src/Util/List.elm (limited to 'elm/battlemap/src/Util') diff --git a/elm/battlemap/src/Util/Array.elm b/elm/battlemap/src/Util/Array.elm new file mode 100644 index 0000000..8088244 --- /dev/null +++ b/elm/battlemap/src/Util/Array.elm @@ -0,0 +1,14 @@ +module Util.Array exposing (update) + +import Array + +update : ( + Int -> + ((Maybe t) -> (Maybe t)) -> + (Array t) -> + (Array t) + ) +update index fun array = + case (fun (Array.get index array)) of + Nothing -> array + (Just e) -> (Array.set index e array) diff --git a/elm/battlemap/src/Util/List.elm b/elm/battlemap/src/Util/List.elm new file mode 100644 index 0000000..c4db397 --- /dev/null +++ b/elm/battlemap/src/Util/List.elm @@ -0,0 +1,12 @@ +module Util.List exposing (pop) + +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)) -- cgit v1.2.3-70-g09d2