1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- type ABC enum {
- type A;
- type B;
- type C;
- };
- const A: ABC := { |ABC| { |A| () } };
- const B: ABC := { |ABC| { |B| () } };
- const C: ABC := { |ABC| { |C| () } };
- function parse-abc:
- &(String) => ABC
- &(str) =>
- if (str = 'A'):
- A,
- elif (str = 'B'):
- B,
- elif (str = 'C'):
- C,
- else:
- { panic 'invalid ABC' };
- function String:
- &(ABC) => String
- &(x) =>
- switch x:
- case A: 'A',
- case B: 'B',
- case C: 'C',
- end;
- function f:
- &(ABC,ABC) => ABC
- &(x,y) =>
- select (x,y):
- case (A,A): A,
- case (A,B): C,
- case (A,C): B,
- case (B,A),(B,B),(B,C): B,
- case (C,A): B,
- case (C,B): A,
- case (C,C): C,
- end;
- do { os::scanln () }
- . { then &(x-str) =>
- { os::scanln () }
- . { then &(y-str) =>
- let z := { f ({parse-abc(x-str)}, {parse-abc(y-str)}) },
- { os::println z.{String} }
- }
- }
- . { crash-on-error };
|