Some basic functions are missing by design:
operations like add an entry, map, concat are provided by Elm's
standard library so there is no need to have a List.Assoc version of them.
Gives the values of all entries that with a given key.
Finds the first tuple with a key that satisfy some predicate.
Removes the first pair with a given key.
Works like removeFirst, but takes a (k -> Bool) predicate.
Removes all entries that have some key.
The same as List.filter,
but the test is made on the key.
If you need a removeAllWith or a findAll then this is your guy.
Sorts the list by key then groups together adjacent entries
with the same key.
type alias User =
{ name : String
, age : Int
}
users : List User
users =
[ { name = "bob", age = 20 }
, { name = "alice", age = 25 }
, { name = "bob", age = 32 }
]
usersByName : List ( String, List User )
usersByName =
|> List.map (\p -> ( p.name, p ))
|> List.Assoc.group
usersByName ==
[ ( "alice", [ { age = 25, name = "alice" } ] )
, ( "bob", [ { age = 20, name = "bob" }, { age = 32, name = "bob" } ] )
]Same as group, but takes a function to map a key to comparable.
Cf. List.sortBy
Same as group, but takes a custom comparison function.
Cf. List.sortWith
Gets the value of the first entry that has a given
key.