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