heptagon/test/good/linear.ept
Gwenal Delaval 87f359a6fd Added main to several tests
Added main to tests
Added dependency statics -> statics2 in scripts
2012-07-17 17:57:04 +02:00

58 lines
1.1 KiB
Text

const m:int = 3
const n:int = 100
node f(a:int^10 at r) returns (o:int^10 at r)
let
o = [ a with [0]=0 ]
tel
node g(a:int^10 at r) returns (o:int^10 at r)
let
o = f(a)
tel
node linplus (a:int at r) returns (u:int at r)
let
u = a
tel
fun swap<<s:int>>(i,j:int; a:float^s at r) returns (o:float^s at r)
var u,v:float; a1:float^s at r;
let
u = a.[i] default 0.0;
v = a.[j] default 0.0;
a1 = [ a with [i] = v ];
o = [ a1 with [j] = u ];
tel
fun plus (a:float;b:float) returns (c:float;d:float)
let
c = a +. b;
d = c;
tel
node shuffle(i_arr, j_arr:int^m; q:int)
returns (v : float)
var t,t_next:float^n at r;last t_init:float^n;last d:float;
let
automaton
state Init
do (t_init,d) = mapfold<<n>> plus (1.0^n, 1.0)
until true then Noupdate
state Noupdate
do
end;
t_next = fold<<m>> (swap<<n>>)(i_arr, j_arr, t);
init<<r>> t = t_init fby t_next;
v = t_next.[q] default 0.0;
tel
node main() returns (v:float)
var c,q:int;i,j:int^m;
let
c = 0 fby if c = n-6 then 0 else c + 1;
i = [c,c+1,c+2];
j = [c+3,c+4,c+5];
v = shuffle(i,j,q);
q = 0 fby if q = n-1 then 0 else q + 1;
tel