raz / conform / run / ArrayEq.raz

42 lines · 1.1 KiB · raw · history · last change 264716cb

1module ArrayEq;
2import Out;
3import SYSTEM;
4
5type Colour = (red, green, blue);
6
7proc say(b: BOOL);
8begin
9 if b then Out.str("T"); else Out.str("F"); end;
10end;
11
12proc main*;
13var
14 a, b: [4]I64; s: []I64; e: []I64;
15 w: [3]U16; c, d: [2]Colour; f: [3]BOOL;
16 m, n: [2]set of Colour; p, q: [2]^I64; x: I64;
17 t: [5]U8;
18begin
19 a := [1, 2, 3, 4]; b := [1, 2, 3, 4];
20 say(a = b); say(a # b);
21 b[3] := 5;
22 say(a = b); say(a # b);
23 s := a[0..3];
24 say(s = a[0..3]); say(s = a); (* of different lengths *)
25 say(a[1..1] = e); say(e = s[0..0]); (* empty *)
26 w := [1, 256, 65535];
27 say(w = [U16(1), 256, 65535]); say(w[2..3] = [U16(65535)]);
28 c := [red, blue]; d := [red, green];
29 say(c = d); d[1] := blue; say(c = d);
30 f := [true, false, true];
31 say(f[0..1] = f[2..3]); say(f[0..1] = [true, false]);
32 m := [{red}, {green, blue}]; n := m;
33 say(m = n); n[1] := {blue}; say(m = n);
34 p := [SYSTEM.ADR(x), nil]; q := p;
35 say(p = q); q[1] := SYSTEM.ADR(x); say(p = q);
36 t := [104, 101, 108, 108, 111];
37 say(t = "hello"); say("hello" = t[0..5]); say("hell" = t[0..4]);
38 say("help" # t[0..4]); say("" = t[0..0]);
39 Out.ln;
40end;
41
42end ArrayEq.