| 1 | (* A module laid out badly. *) |
| 2 | module Messy; |
| 3 | import Out,Rt; |
| 4 | |
| 5 | const |
| 6 | max* =10; |
| 7 | min=-1; |
| 8 | |
| 9 | type |
| 10 | Pair* = record |
| 11 | a*,b: I64; (* two numbers *) |
| 12 | end; |
| 13 | Shape = variant |
| 14 | circle(r: I64); |
| 15 | dot; |
| 16 | end; |
| 17 | |
| 18 | (* the bigger *) |
| 19 | proc max2*(a,b:I64):I64; |
| 20 | var m : I64; |
| 21 | begin |
| 22 | if a>b then m:=a; |
| 23 | elsif a=b then |
| 24 | m :=a ; |
| 25 | else |
| 26 | m:= b;end; |
| 27 | return m; |
| 28 | end; |
| 29 | |
| 30 | proc area(s: Shape): I64; |
| 31 | begin |
| 32 | match s of |
| 33 | | circle(r): return 3*r*r; |
| 34 | | dot: |
| 35 | return 0; |
| 36 | end; |
| 37 | end; |
| 38 | |
| 39 | proc main*; |
| 40 | var i,s:I64; p: Pair; |
| 41 | begin |
| 42 | s:=0; |
| 43 | for i:=-3 to max-1 do s:=s+i*2- -1;end; |
| 44 | repeat |
| 45 | s := s-1 ; |
| 46 | until s<0; |
| 47 | if (s # -1) or (max2(3,4) # 4) |
| 48 | or (area({dot}) # 0) then Rt.stop("Messy"); end; |
| 49 | s:=s&~3|s xor 1 & max |
| 50 | | 4; |
| 51 | p := {a: -s, b:2}; |
| 52 | Out.int(p.a); (* the first *) |
| 53 | Out.ln; |
| 54 | (* and done: |
| 55 | a comment that moves |
| 56 | with its line *) |
| 57 | end; |
| 58 | |
| 59 | end Messy. |