ligo/src/test/contracts/set_arithmetic-1.ligo

18 lines
447 B
Plaintext
Raw Normal View History

// Test set iteration in PascaLIGO
2020-02-27 17:51:29 +01:00
function iter_op (const s : set (int)) : int is
block {
var r : int := 0;
function aggregate (const i : int) : unit is
2020-02-27 17:51:29 +01:00
block {
r := r + i
} with unit;
set_iter (aggregate, s)
} with r // ALWAYS RETURNS 0
2019-09-24 00:26:39 +02:00
2020-02-27 17:51:29 +01:00
function fold_op (const s : set (int)) : int is
block {
2020-02-27 17:51:29 +01:00
function aggregate (const i : int; const j : int) : int is
i + j
2020-02-27 17:51:29 +01:00
} with set_fold (aggregate, s, 15)