module AggregateScorers exposing (..) import Dict exposing (Dict) aggregateScorers : List String -> List String aggregateScorers playerNames = let dict = List.foldl (\elem acc -> if Dict.member elem acc then Dict.update elem (Maybe.map <| \count -> count + 1) acc else Dict.insert elem 1 acc ) Dict.empty playerNames in List.map (\orig -> let val = Dict.get orig dict in if val == Just 1 then orig else orig ++ " (" ++ String.fromInt (Maybe.withDefault 0 val) ++ ")" ) <| List.sort <| Dict.keys dict