t_setops.mod 512 B

123456789101112131415
  1. MODULE tsetops;
  2. // SET OF enum + SET OF char-range, INCL/EXCL, SHIFT/ROTATE.
  3. TYPE Colour = (Blue, Red, Green, White);
  4. CS = SET OF Colour;
  5. Chars = SET OF ['A'..'z'];
  6. VAR x : CS; c : Chars; r : CS;
  7. VAR ExitCode : INTEGER;
  8. BEGIN
  9. x := CS {};
  10. INCL(x, Red); INCL(x, Blue); EXCL(x, Red);
  11. c := Chars {'A'};
  12. r := SHIFT(CS {Blue}, 1); (* {Blue}(bit 0) -> {Red}(bit 1) *)
  13. IF (Blue IN x) AND NOT (Red IN x) AND ('A' IN c) AND (Red IN r)
  14. THEN ExitCode := 42 ELSE ExitCode := 1 END
  15. END tsetops.