heptagon/test/good/array1.ept
Cédric Pasteur 8f4220e08d Made Eupdate dynamic
Modifying an array with
 [ a with [i] = v ]
should expected a dynamic (not static) value
for i (nothing happens if i is in the wrong range).
This is the same behaviour as in Scade and it is 
useful eg to modify an array in a foldi.
2010-07-28 12:34:07 +02:00

43 lines
664 B
Text

const n:int = 42
const m:int = 52
node concatenate(a:int^n; b:int^m) returns (o1, o2: int^(n+m))
let
o1 = a @ b;
o2 = b @ a;
tel
node slicing (a:int^n) returns (u1,u2 : int^3)
let
u1 = a[0 .. 2];
u2 = a[3 .. 5];
tel
node elt (a:int^m) returns (o:int^m)
var x : int;
let
x = a[2] + 1;
o = [ a with [1] = x ];
tel
node upd_dyn(a:int^m; i:int) returns (o:int^m)
let
o = [ a with [i] = a[0] ];
tel
node elt_dyn (a:int^m; i:int) returns (o:int^m)
var x : int;
let
x = a.[i] default 3;
o = [ a with [1] = x ];
tel
node ten (i: int) returns (o:int^m)
let
o = i^m;
tel
node constant(a,b:int) returns (o:int^4)
let
o = [a,b,a,b];
tel