2019-09-21 14:59:48 -07:00
|
|
|
// 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;
|
2019-11-18 16:10:48 +01:00
|
|
|
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
|
2019-11-18 16:10:48 +01:00
|
|
|
block {
|
2020-02-27 17:51:29 +01:00
|
|
|
function aggregate (const i : int; const j : int) : int is
|
2019-11-18 16:10:48 +01:00
|
|
|
i + j
|
2020-02-27 17:51:29 +01:00
|
|
|
} with set_fold (aggregate, s, 15)
|