aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Utils
diff options
context:
space:
mode:
authorJoris2016-04-06 14:28:16 +0200
committerJoris2016-04-06 14:28:16 +0200
commitac8a7c6210e2f430a3015e8004ff0726ef24d63b (patch)
tree0df4ccbef7fca622a0ee4e89d35b9ce7d2d6eb09 /src/client/elm/Utils
parentd889c728c6ef1462fdeb56891de8d4d1a3df70c6 (diff)
Add payments by month in stat
Diffstat (limited to 'src/client/elm/Utils')
-rw-r--r--src/client/elm/Utils/List.elm13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/client/elm/Utils/List.elm b/src/client/elm/Utils/List.elm
new file mode 100644
index 0000000..85cdc24
--- /dev/null
+++ b/src/client/elm/Utils/List.elm
@@ -0,0 +1,13 @@
+module Utils.List
+ ( groupBy
+ ) where
+
+import Dict
+
+groupBy : (a -> comparable) -> List a -> List (comparable, List a)
+groupBy f xs =
+ let addItem item dict =
+ let groupItems = Dict.get (f item) dict |> Maybe.withDefault []
+ in Dict.insert (f item) (item :: groupItems) dict
+ in List.foldr addItem Dict.empty xs
+ |> Dict.toList