PERMS.LST 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Listing:
  2. 1 IMPLEMENTATION MODULE perms;
  3. 2
  4. 3 PROCEDURE NextPerm(n:CARDINAL; VAR s:ARRAY OF BYTE;
  5. ***** ^ undeclared identifier
  6. 4 VAR wrap:BOOLEAN);
  7. 5 VAR
  8. 6 i:CARDINAL; (* s[i-1] is the most significant byte changed *)
  9. 7 j:CARDINAL; (* s[j] is the byte to be swapped with s[i-1] *)
  10. 8 tmp:BYTE;
  11. ***** ^ undeclared identifier
  12. 9
  13. 10
  14. 11
  15. 12 BEGIN
  16. 13 IF n = 0 THEN
  17. 14 wrap := TRUE;
  18. 15 RETURN;
  19. 16 END;
  20. 17 i := n - 1;
  21. 18
  22. 19
  23. 20
  24. 21 LOOP
  25. 22 IF i = 0 THEN
  26. 23 wrap := TRUE;
  27. 24 EXIT;
  28. 25 END;
  29. 26
  30. 27
  31. 28
  32. 29 IF s[i-1] < s[i] THEN
  33. ***** ^ not supported yet
  34. ***** ^ not supported yet
  35. ***** ^ not supported yet
  36. ***** ^ not supported yet
  37. 30 j := n - 1;
  38. 31 WHILE s[j] <= s[i-1] DO
  39. ***** ^ not supported yet
  40. ***** ^ not supported yet
  41. ***** ^ not supported yet
  42. ***** ^ not supported yet
  43. 32 j := j - 1;
  44. 33 END;
  45. 34 tmp := s[j]; s[j] := s[i-1]; s[i-1] := tmp; (* swap *)
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. ***** ^ not supported yet
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. ***** ^ not supported yet
  55. ***** ^ not supported yet
  56. 35 wrap := FALSE;
  57. 36 EXIT;
  58. 37 END;
  59. 38 i := i - 1;
  60. 39 END;
  61. 40
  62. 41
  63. 42
  64. 43
  65. 44 (* s[i]..s[n-1] are in reverse order, reversing them
  66. 45 yields the minimum permutation we require *)
  67. 46 j := n - 1;
  68. 47 WHILE i < j DO
  69. 48 tmp := s[j]; s[j] := s[i]; s[i] := tmp;
  70. ***** ^ not supported yet
  71. ***** ^ not supported yet
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. ***** ^ not supported yet
  75. ***** ^ not supported yet
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. 49 i := i + 1;
  81. 50 j := j - 1;
  82. 51 END;
  83. 52 END NextPerm;
  84. ***** ^ not supported yet
  85. 53
  86. 54 END perms.
  87. ***** ^ not supported yet
  88. 55
  89. 32 errors