raz / conform / run / MatchEnumList.raz

34 lines · 537 B · raw · history · last change 57a5dff9

1module MatchEnumList;
2import Out;
3
4type Op = (plus, minus, times, over, rest);
5
6proc kind(op: Op): INT;
7begin
8 match op of
9 | plus, minus: return 1;
10 | times: return 2;
11 | over, rest: return 3;
12 end;
13end;
14
15proc wide(op: Op): INT;
16var n: INT;
17begin
18 n := 0;
19 match op of
20 | minus, over, plus: n := 10;
21 | else: n := 20;
22 end;
23 return n;
24end;
25
26proc main*;
27var op: Op;
28begin
29 for op := plus to rest do
30 Out.int(kind(op)); Out.str(" "); Out.int(wide(op)); Out.ln;
31 end;
32end;
33
34end MatchEnumList.