2011-05-02 14:58:15 +02:00
|
|
|
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 ];
|
2012-07-17 17:57:04 +02:00
|
|
|
o = [ a1 with [j] = u ];
|
|
|
|
tel
|
|
|
|
|
|
|
|
fun plus (a:float;b:float) returns (c:float;d:float)
|
|
|
|
let
|
|
|
|
c = a +. b;
|
|
|
|
d = c;
|
2011-05-02 14:58:15 +02:00
|
|
|
tel
|
|
|
|
|
|
|
|
node shuffle(i_arr, j_arr:int^m; q:int)
|
|
|
|
returns (v : float)
|
2012-07-17 17:57:04 +02:00
|
|
|
var t,t_next:float^n at r;last t_init:float^n;last d:float;
|
2011-05-02 14:58:15 +02:00
|
|
|
let
|
2012-07-17 17:57:04 +02:00
|
|
|
automaton
|
|
|
|
state Init
|
|
|
|
do (t_init,d) = mapfold<<n>> plus (1.0^n, 1.0)
|
|
|
|
until true then Noupdate
|
|
|
|
state Noupdate
|
|
|
|
do
|
|
|
|
end;
|
2011-05-02 14:58:15 +02:00
|
|
|
t_next = fold<<m>> (swap<<n>>)(i_arr, j_arr, t);
|
2012-07-17 17:57:04 +02:00
|
|
|
init<<r>> t = t_init fby t_next;
|
2011-05-02 14:58:15 +02:00
|
|
|
v = t_next.[q] default 0.0;
|
2012-07-17 17:57:04 +02:00
|
|
|
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
|