Version: 0.19.0


let empty: map<'key, 'value>

Create an empty map.

type move = [int, int];
type register = map<address, move>;
let empty: register = Map.empty;
let literal: (input: list<['key, 'value]>) => map<'key, 'value>

Create a non-empty map.

let moves: register =
[("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" as address), [1, 2]],
[("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), [0, 3]]]));
let find_opt : (key: 'key, map: map <'key, 'value>) => option <'value>

Retrieve a (option) value from a map with the given key. Returns None if the key is missing and the value otherwise.

let my_balance: option<move> =
Map.find_opt(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), moves);
let update: (key: 'key, new_value: option<'value>, map: map<'key, 'value>) => map <'key, 'value>

Note: when None is used as a value, the key and associated value is removed from the map.

let updated_map : register =
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), Some ([4, 9]), moves);

Similar to update but it also returns the value that was previously stored in the map

let add: (key: 'key, value: 'value, map: map<'key, 'value>) => map<'key, 'value>
let add = (m: register): register =>
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), [4, 9], m);
let remove: (key: key, map: map<'key, 'value>) => map<'key, 'value>
let updated_map : register =
Map.remove (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), moves);
let iter: (iter: (['key, 'value]) => unit, map: map<'key, 'value>) => unit
let iter_op = (m : register) : unit => {
let predicate = ([i, j] : [address, move]): unit => assert (j[0] > 3);
Map.iter (predicate, m);
let map: (mapper: (item: ['key, 'value]) => ['mapped_key, 'mapped_item], map: map<key, value>) => map<mapped_key, mapped_value>
let fold: (iter: ((accumulator: 'accumulator, item: ['key, 'value]) => 'accumulator), map: map<'key, 'value>, accumulator: 'accumulator) => 'accumulator
let fold_op = (m : register): int => {
let folded = ([i,j]: [int, [address, move]]):int => i + j[1][1];
return Map.fold (folded, m, 5);
let size: (map: map<'key, 'value>) => nat

Returns the number of items in the map.

let mem : (key: 'key, map: map<'key, 'value>) => bool

Checks if a key exists in the map.