# cloning resource clone() procedure wvec (int v[*]) { for [ i = 1 to ub(v) ] { writes (v[i], " ") } write() } procedure ident (int i) returns int j{ write ("ident", i) j = i } int v[1:5] int n v = ([5] 8) wvec(v) v = (1, [3] 9, 7) wvec(v) # ident() should be called only once wvec (([2] 2, 1, [5] ident(5), 1, [3] 3)) # ident() should not be called at all wvec ((1, 2, 3, [0] ident(0), 4, 5, 6)) # claracter cloning char x[1:10] x = ([10] 'x') write(x) x = ([0]'a', [3]'b', [0]'c', [3]'d', [0]'e', [4]'f') write (x) n = 5 x[3:n] = ([n-2] 'y') x[n:7] = ([8-n] 'z') n = 0 x[1:n] = ([n] '?') write(x) x = ('A', [6]'a', 'r', 'g', 'h') write(x) # variable clone count put("n? "); read(n); char a[1:n] = ([n] 'a'); char b[1:n] = ([n] 'b'); write(n,a,b); # this used to get segmentation fault on Iris int flag[0,5] = ([0] ([5]0)) write ("flag bounds:", lb(flag), ub(flag), lb(flag,2), ub(flag,2)) write ("done") end