LIST_ASSOC
- All Known Implementing Modules:
-
ListAssoc
-
Utility functions that deals with association lists.
-
Value summary
|
val add : ''a * ''b -> (''a * ''b) list -> (''a * ''b) list
adds a new association, ensuring that only one association has this key.
|
val addAll : (''a * ''b) list -> (''a * ''b) list -> (''a * ''b) list
adds a list of new association, ensuring that only one association has the added keys.
|
val areAllIn : (''a * ''b) list -> (''a * ''b) list -> bool
test if the first association list is a sub-list (without ordering consideration)
of the second list.
|
val assoc : ''a -> (''a * ''b) list -> ''b option
test if an association belongs to the association list.
|
val existsAllKey : ''a list -> (''a * ''b) list -> bool
test if all the keys occurs in the association list.
|
val filterKey : ''a list -> (''a * ''b) list -> (''a * ''b) list
returns all the elements of the association for which the key belongs to
the given key list.
|
val getKeyList : (''a * ''b) list -> ''a list
returns the list of keys.
|
val getValueList : (''a * ''b) list -> ''b list
returns the list of values.
|
val memberKey : ''a -> (''a * ''b) list -> bool
test if a key belongs to the association list.
|
val partitionWithKeyList
: ''a list -> (''a * ''b) list -> (''a * ''b) list * (''a * ''b) list
partitions an association list in two list, according to the keys bonlonging to
the given key list.
|
val removeAllKey : ''a list -> (''a * ''b) list -> (''a * ''b) list
returns the association list without any association matching the given key list.
|
val removeKey : ''a -> (''a * ''b) list -> (''a * ''b) list
returns the association list without any association matching the given key.
|
val union : (''a * ''b) list -> (''a * ''b) list -> (''a * ''b) list option
unite to association lists.
|
val unionFlat : (''a * ''b) list list -> (''a * ''b) list option
unite many association lists, flattening them.
|
getKeyList
fun getKeyList l : (''a * ''b) list -> ''a list
-
returns the list of keys.
-
- Parameters:
-
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
the list of keys [x1, ..., xn].
getValueList
fun getValueList l : (''a * ''b) list -> ''b list
-
returns the list of values.
-
- Parameters:
-
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
the list of keys [v1, ..., vn].
memberKey
fun memberKey x l : ''a -> (''a * ''b) list -> bool
-
test if a key belongs to the association list.
-
- Parameters:
-
-
x
-
the key to test.
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
true if and only if x is one of x1, ..., xn.
assoc
fun assoc (x, v) l : ''a -> (''a * ''b) list -> ''b option
-
test if an association belongs to the association list.
-
- Parameters:
-
-
x
-
the key to test.
-
v
-
the value to test.
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
true if and only if (x, v) is one of (x1,v1), ..., (xn, vn).
filterKey
fun filterKey kl l : ''a list -> (''a * ''b) list -> (''a * ''b) list
-
returns all the elements of the association for which the key belongs to
the given key list.
-
- Parameters:
-
-
kl
-
the key list.
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
(xi,vi) for all i such that xi belongs to kl.
removeKey
fun removeKey k l : ''a -> (''a * ''b) list -> (''a * ''b) list
-
returns the association list without any association matching the given key.
-
- Parameters:
-
-
k
-
the key.
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
(xi,vi) for all i such that xi <> k.
removeAllKey
fun removeAllKey kl l : ''a list -> (''a * ''b) list -> (''a * ''b) list
-
returns the association list without any association matching the given key list.
-
- Parameters:
-
-
kl
-
the key list.
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
(xi,vi) for all i such that xi does not belongs to kl.
add
fun add (x, v) l : ''a * ''b -> (''a * ''b) list -> (''a * ''b) list
-
adds a new association, ensuring that only one association has this key.
-
- Parameters:
-
-
xl
-
the key.
-
v
-
the value.
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
(x,v)::l' where l' is l without all associations having key k.
addAll
fun addAll l1 l2 : (''a * ''b) list -> (''a * ''b) list -> (''a * ''b) list
-
adds a list of new association, ensuring that only one association has the added keys.
-
- Parameters:
-
-
l1
-
the association list [(x1,v1), ..., (xn, vn)].
-
l2
-
the association list [(y1,w1), ..., (ym, wm)].
- Returns:
-
[(x1,v1), ..., (xn, vn)]@l' where l' is l without all associations having
key belonging to x1, ..., xn.
union
fun union l1 l2
: (''a * ''b) list -> (''a * ''b) list -> (''a * ''b) list option
-
unite to association lists. Same key must have the same values.
-
- Parameters:
-
-
l1
-
the association list [(x1,v1), ..., (xn, vn)].
-
l2
-
the association list [(y1,w1), ..., (ym, wm)].
- Returns:
-
l1'@l2 (where l1' is l1 without all associations having
key belonging to y1, ..., yn), or NONE if the same key appears with
different values.
unionFlat
fun unionFlat ll : (''a * ''b) list list -> (''a * ''b) list option
-
unite many association lists, flattening them. Same key must have the same values.
-
- Parameters:
-
-
ll
-
the association list list.
- Returns:
-
the flattened union (as in union), or NONE if the same key appears with
different values.
existsAllKey
fun existsAllKey kl l : ''a list -> (''a * ''b) list -> bool
-
test if all the keys occurs in the association list.
-
- Parameters:
-
-
kl
-
the key list.
-
l
-
the association list.
- Returns:
-
true if and only if all key in kl belong to l.
areAllIn
fun areAllIn l1 l2 : (''a * ''b) list -> (''a * ''b) list -> bool
-
test if the first association list is a sub-list (without ordering consideration)
of the second list.
-
- Parameters:
-
-
l1
-
the first association list.
-
l2
-
the second association list.
- Returns:
-
true if and only if all associations in l1 belongs to l2.
partitionWithKeyList
fun partitionWithKeyList k1 l
: ''a list -> (''a * ''b) list -> (''a * ''b) list * (''a * ''b) list
-
partitions an association list in two list, according to the keys bonlonging to
the given key list.
-
- Parameters:
-
-
kl
-
the key list.
-
l
-
the association list [(x1,v1), ..., (xn, vn)].
- Returns:
-
([(xi,vi), ..., (xk, vk)], [(xj,vj), ..., (xl, vl)]) where
(xi, ..., xk) belongs to kl, and (xj, ..., xl) does not belongs to kl.