summaryrefslogblamecommitdiff
path: root/tests/count.scade
blob: c5ce47de9f56e84ecf897a548b6a4b8840960c51 (plain) (tree)



































                                                                      
node count() returns (c: int)
let
	c = 0 -> (1 + pre c);
tel

node resettable_count (r: bool) returns (c: int)
let
    c = (restart count every r)();
tel

node nat() returns (s: int) s = 1 -> (1 + pre s);

node rst_clk(rst: bool; clock h: bool)
    returns (s: int; t: int)
let
    s = (restart nat every rst) ();
    t = merge(h; ((restart nat every rst) (() when h)); 0 when not h);
tel

node even_times(c: bool; i: int) returns (o: int)
let
    automaton
        initial state EVEN
        unless if c resume ODD;
        let
            o = i+1;
        tel

        state ODD
        unless if c resume EVEN;
        let
            o = -2 * i;
        tel
    returns o;
tel