20 lines
319 B
Text
20 lines
319 B
Text
|
const n:int = 43
|
||
|
|
||
|
node f(a:int^n; i:int) returns (o:int^n; m:int)
|
||
|
let
|
||
|
m = a.[i] default 0;
|
||
|
o = i^n;
|
||
|
tel
|
||
|
|
||
|
node sumdup (a, acc_in:int) returns (o:int; acc_out:int)
|
||
|
let
|
||
|
acc_out = acc_in + a;
|
||
|
o = acc_out;
|
||
|
tel
|
||
|
|
||
|
node p(a:int^n) returns (o:int^n)
|
||
|
var acc:int;
|
||
|
let
|
||
|
(o, acc) = mapfold sumdup <<n>>(a, 0);
|
||
|
tel
|