type integer = int 64; box gen in (n::integer) out (n',r,s::integer) match x -> (x+1,x,x); stream output to "std_out"; wire gen (gen.n' initially 0) (gen.n,hsq.n,id.x); box id in (x::integer) out (x'::integer) match x -> x; wire id (gen.s) (show.gen); box hsq in (n::integer) out (r::integer) match _ -> _ boxes box sq in (n,nc,c,s::integer) out (nc',c',s',r::integer) match (*,_,0,s) -> (*,*,*,s) | (*,nc,c,s) -> (nc,c-1,s+nc,*) | (n,*,*,*) -> (n,n,0,*) ; wire sq (hsq.n,sq.nc',sq.c',sq.s') (sq.nc,sq.c,sq.s,hsq.r); end; wire hsq (gen.r) (show.sq); box show in (gen,sq::integer) out (s::string) match (g,s) -> "gen: "++g as string++"; sq: "++s as string++"\n" | (*,s) -> "sq: "++s as string++"\n" | (g,*) -> "gen: "++g as string++"\n"; wire show (id.x',hsq.r) (output);