test List.iter and List.map in cameligo
This commit is contained in:
parent
9c3c40c9ef
commit
ac449d2cb3
@ -16,3 +16,11 @@ let%entry main (p : param) storage =
|
||||
let fold_op (s : int list) : int =
|
||||
let aggregate = fun (prec : int) (cur : int) -> prec + cur in
|
||||
List.fold s 10 aggregate
|
||||
|
||||
let map_op (s : int list) : int list =
|
||||
let aggregate = fun (cur : int) -> cur + 1 in
|
||||
List.map s aggregate
|
||||
|
||||
let iter_op (s : int list) : unit =
|
||||
let do_nothing = fun (cur : int) -> unit in
|
||||
List.iter s do_nothing
|
||||
|
@ -699,6 +699,8 @@ let mligo_list () : unit result =
|
||||
let%bind () = expect_eq_evaluate program "x" (e_list []) in
|
||||
let%bind () = expect_eq_evaluate program "y" (e_list @@ List.map e_int [3 ; 4 ; 5]) in
|
||||
let%bind () = expect_eq_evaluate program "z" (e_list @@ List.map e_int [2 ; 3 ; 4 ; 5]) in
|
||||
let%bind () = expect_eq program "map_op" (aux [2 ; 3 ; 4 ; 5]) (aux [3 ; 4 ; 5 ; 6]) in
|
||||
let%bind () = expect_eq program "iter_op" (aux [2 ; 3 ; 4 ; 5]) (e_unit ()) in
|
||||
ok ()
|
||||
|
||||
let lambda_mligo () : unit result =
|
||||
|
Loading…
Reference in New Issue
Block a user