2019-09-24 15:54:34 +04:00
|
|
|
type foobar = (int , int) map
|
|
|
|
|
2019-09-27 19:52:40 +04:00
|
|
|
let empty_map : foobar = Map.empty
|
2019-09-24 15:54:34 +04:00
|
|
|
|
2019-09-27 19:52:40 +04:00
|
|
|
let map1 : foobar = Map.literal
|
|
|
|
[ (144 , 23) ; (51 , 23) ; (42 , 23) ; (120 , 23) ; (421 , 23) ]
|
|
|
|
let map2 : foobar = Map [ (23 , 0) ; (42 , 0) ]
|
2019-09-24 16:29:18 +04:00
|
|
|
|
2019-09-27 19:52:40 +04:00
|
|
|
let set_ (n : int) (m : foobar) : foobar =
|
|
|
|
Map.update 23 (Some n) m
|
|
|
|
|
|
|
|
let rm (m : foobar) : foobar = Map.remove 42 m
|
|
|
|
|
2019-10-11 05:26:28 +04:00
|
|
|
(* Dummy test so that we can add the same test for PascaLIGO *)
|
|
|
|
let patch_ (m : foobar) : foobar = Map.literal [ (0, 5) ; (1, 6) ; (2, 7) ]
|
|
|
|
|
2019-10-12 00:23:29 +04:00
|
|
|
(* Second dummy test, see above *)
|
|
|
|
let patch_empty (m : foobar) : foobar = Map.literal [ (0, 0) ; (1, 1) ; (2, 2) ]
|
|
|
|
|
2019-10-14 21:19:18 +04:00
|
|
|
(* Third dummy test, see above *)
|
|
|
|
let patch_deep (m: foobar * nat) : foobar * nat = (Map.literal [ (0, 0) ; (1, 9) ; (2, 2) ], 10p)
|
|
|
|
|
2019-09-27 19:52:40 +04:00
|
|
|
let size_ (m : foobar) : nat = Map.size m
|
|
|
|
|
|
|
|
let gf (m : foobar) : int = Map.find 23 m
|
|
|
|
|
|
|
|
let get (m : foobar) : int option = Map.find_opt 42 m
|
|
|
|
let get_ (m : foobar) : int option = Map.find_opt 42 m
|
|
|
|
|
|
|
|
let iter_op (m : foobar) : unit =
|
|
|
|
let assert_eq = fun (i : int) (j : int) -> assert(i=j) in
|
|
|
|
Map.iter m assert_eq
|
|
|
|
|
|
|
|
let map_op (m : foobar) : foobar =
|
|
|
|
let increment = fun (i : int) (j : int) -> j+1 in
|
|
|
|
Map.map m increment
|
|
|
|
|
|
|
|
let fold_op (m : foobar) : foobar =
|
|
|
|
let aggregate = fun (i : int) (j : (int * int)) -> i + j.(0) + j.(1) in
|
2019-10-08 18:41:47 +04:00
|
|
|
Map.fold m 10 aggregate
|
|
|
|
|
|
|
|
let deep_op (m : foobar) : foobar =
|
|
|
|
let coco = (0,m) in
|
|
|
|
let coco = (0 , Map.remove 42 coco.(1)) in
|
|
|
|
let coco = (0 , Map.update 32 (Some 16) coco.(1)) in
|
2019-10-11 05:26:28 +04:00
|
|
|
coco.(1)
|