
fun substr (x,m: int) returns (d: int; m2:int)
let
  d = x - m;
  m2 = m;
tel

fun mean<<n: int>> (i: int^n) returns (m: int)
let
  m = (fold (+) <<n>> (i,0) )/n
tel


node normalized_movie<<n: int>> (i: int^n) returns (im: int^n)
var m: async int; trash: int;
let
  m = async mean<<n>>(i);
  (im,trash) = mapfold substr <<n>> (i fby i, 0 -> !(pre m))
tel


node main () returns (r:int)
var f: int^100; nf: int^100; x: int;
let
  x = 0 fby x+1;
  f = x^100;
  nf = normalized_movie<<100>>(f);
  r = mean<<100>>(nf)
tel

