Map module¶
The Map modules defines functions helper for maps.
variables:¶
cardinal : map (‘v) -> int¶
cardinal aset : return the number of elements in the set.
Exemple:¶
% let $myMap = -< 1: "Tintin" , 2: "Haddock" >-
% $Map.cardinal $myMap
2
is_in: map (‘k, ‘v) -> ‘k -> bool¶
is_in map key: return True if the key given as second argument exist in the map given as first argument. Else return False.
Exemples:¶
% let $myMap = -< 1: "Tintin" , 2: "Haddock" >-
% $Map.is_in $myMap 3
False
% $Map.is_in $myMap 2
True
get : map (‘k, ‘v) -> ‘k -> option ‘v¶
get m k: return the optionnal value at position k in map m.
Exemples:¶
% let $myMap = -< 1: "Tintin" , 2: "Haddock" >-
% $Map.get $myMap 2
Some ("Haddock")
% $Map.get $myMap 3
None
union: map (‘k, ‘v) -> map (‘k, ‘v) -> map (‘k, ‘v)¶
union m1 m2 do the union of map m1 and m2. If both map contains an entry for the same key, the value of the second map is associated to it.
Exemples:¶
% $Map.union -< 1: "Camembert" , 2: "Beaufort">- -< 0: "Reblochon", 1: "Comté" >-
-< 0 : Reblochon , 1 : Comté , 2 : Beaufort >-