2019-09-21 14:59:48 -07:00
|
|
|
// Test set iteration in PascaLIGO
|
|
|
|
|
2019-08-21 11:41:57 +02:00
|
|
|
function iter_op (const s : set(int)) : int is
|
|
|
|
begin
|
2019-11-18 16:10:48 +01:00
|
|
|
var r : int := 0 ;
|
|
|
|
function aggregate (const i : int) : unit is
|
|
|
|
begin
|
|
|
|
r := r + i ;
|
|
|
|
end with unit ;
|
2019-11-20 12:16:31 +00:00
|
|
|
set_iter(aggregate, s) ;
|
2019-08-21 11:41:57 +02:00
|
|
|
end with r
|
2019-09-24 00:26:39 +02:00
|
|
|
|
|
|
|
function fold_op (const s : set(int)) : int is
|
2019-11-18 16:10:48 +01:00
|
|
|
block {
|
|
|
|
function aggregate (const i : int ; const j : int) : int is
|
|
|
|
i + j
|
2019-11-20 12:16:31 +00:00
|
|
|
} with set_fold(aggregate, s , 15)
|