2010-07-09 10:35:54 +02:00
|
|
|
const n:int = 42
|
|
|
|
|
2011-06-27 11:07:40 +02:00
|
|
|
|
2010-07-09 10:35:54 +02:00
|
|
|
node plusone(a:int) returns (o:int)
|
|
|
|
let
|
|
|
|
o = a+1;
|
2010-07-09 13:27:06 +02:00
|
|
|
tel
|
2010-07-09 10:35:54 +02:00
|
|
|
|
2011-06-27 11:07:40 +02:00
|
|
|
fun f() returns (o:int^n)
|
|
|
|
let
|
|
|
|
o = mapi<<n>> plusone ();
|
|
|
|
tel
|
|
|
|
|
2010-07-09 10:35:54 +02:00
|
|
|
node g(a:int^n) returns (o:int^n)
|
|
|
|
let
|
2011-03-21 20:45:48 +01:00
|
|
|
o = map<<n>> plusone (a);
|
2010-07-09 10:35:54 +02:00
|
|
|
tel
|
|
|
|
|
|
|
|
node sum_acc (a, acc_in:int) returns (acc_out:int)
|
|
|
|
let
|
2010-07-09 13:27:06 +02:00
|
|
|
acc_out = acc_in + a;
|
2010-07-09 10:35:54 +02:00
|
|
|
tel
|
|
|
|
|
|
|
|
node h(a:int^n) returns (m:int)
|
|
|
|
let
|
2011-03-21 20:45:48 +01:00
|
|
|
m = fold<<n>> sum_acc (a, 0);
|
2010-07-09 10:35:54 +02:00
|
|
|
tel
|
|
|
|
|
|
|
|
node sum_dup (a, acc_in:int) returns (o:int; acc_out:int)
|
|
|
|
let
|
2010-07-09 13:27:06 +02:00
|
|
|
acc_out = acc_in + a;
|
|
|
|
o = acc_out;
|
2010-07-09 10:35:54 +02:00
|
|
|
tel
|
|
|
|
|
|
|
|
node p(a:int^n) returns (o:int^n)
|
|
|
|
var acc:int;
|
|
|
|
let
|
2011-03-21 20:45:48 +01:00
|
|
|
(o, acc) = mapfold<<n>> sum_dup (a, 0);
|
2010-07-09 10:35:54 +02:00
|
|
|
tel
|
|
|
|
|
|
|
|
node k(a,b:int^n) returns (o:int^n)
|
|
|
|
let
|
2011-03-21 20:45:48 +01:00
|
|
|
o = map<<n>> (+) (a,b);
|
2010-07-09 10:35:54 +02:00
|
|
|
tel
|
|
|
|
|
|
|
|
node iter_reset(a:int^n; r:bool) returns (o:int^n)
|
|
|
|
let
|
|
|
|
reset
|
2011-03-21 20:45:48 +01:00
|
|
|
o = map<<n>> plusone (a);
|
2010-07-09 13:27:06 +02:00
|
|
|
every (r & r)
|
2011-03-22 09:28:41 +01:00
|
|
|
tel
|
|
|
|
|
|
|
|
node m(t:int^n; a:int; i:int) returns (o:int)
|
|
|
|
let
|
|
|
|
o = a * i + t[0];
|
|
|
|
tel
|
|
|
|
|
|
|
|
node itmapi(a:int^n) returns (o:int^n)
|
|
|
|
let
|
2011-05-23 09:24:57 +02:00
|
|
|
o = mapi <<n>> m<(a)>(a);
|
|
|
|
tel
|
2012-07-16 18:49:08 +02:00
|
|
|
|
|
|
|
node main() returns (t1,t2,t3,t4,t5,t6:int^n;x1:int)
|
|
|
|
var r:bool;
|
|
|
|
let
|
|
|
|
t1 = f();
|
|
|
|
t2 = g(t1);
|
|
|
|
x1 = h(t2);
|
|
|
|
t3 = p(t2);
|
|
|
|
t4 = k(t1,t3);
|
|
|
|
r = false fby false fby true fby r;
|
|
|
|
t5 = iter_reset(t4,r);
|
|
|
|
t6 = itmapi(t5);
|
|
|
|
tel
|