main1.red 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. % Simple 1 file test
  2. % This is program MAIN1.RED
  3. IN "XXX-HEADER.RED"$
  4. On SYSLISP;
  5. Procedure FirstCall;
  6. <<Init();
  7. PutC Char F;
  8. PutC Char !a;
  9. PutC Char !c;
  10. PutC Char !=;
  11. PutInt Ifact 10;
  12. Terpri();
  13. PutC Char T;
  14. PutC Char !e;
  15. PutC Char !s;
  16. PutC Char !t;
  17. PutC Char F;
  18. PutC Char !a;
  19. PutC Char !c;
  20. PutC Char !t;
  21. Terpri();
  22. TestFact();
  23. Terpri();
  24. PutC Char T;
  25. PutC Char !e;
  26. PutC Char !s;
  27. PutC Char !t;
  28. PutC Char T;
  29. PutC Char !a;
  30. PutC Char !k;
  31. Terpri();
  32. TestTak();
  33. Quit;>>;
  34. procedure terpri();
  35. PutC Char EOL;
  36. Procedure TestFact();
  37. << PutInt Timc();
  38. Terpri();
  39. ArithmeticTest 10000;
  40. PutInt Timc();
  41. Terpri();
  42. >>;
  43. Procedure ArithmeticTest (N);
  44. begin scalar I;
  45. I:= 0;
  46. loop:
  47. if Igreaterp(I,N) then return NIL;
  48. Fact 9;
  49. I := iadd1 I;
  50. goto loop
  51. end;
  52. procedure TestTak();
  53. <<PutInt Timc();
  54. Terpri();
  55. PutInt TopLevelTak (18,12,6);
  56. Terpri();
  57. PutInt Timc();
  58. Terpri();>>;
  59. syslsp procedure Fact (N);
  60. If ilessp(N,2) then 1 else LongTimes(N,Fact isub1 N);
  61. syslsp procedure Ifact u;
  62. Begin scalar m;
  63. m:=1;
  64. L1: if u eq 1 then return M;
  65. M:=LongTimes(U,M);
  66. u:=u-1;
  67. PutInt(u);
  68. Terpri();
  69. PutInt(M);
  70. Terpri();
  71. goto L1;
  72. end;
  73. in "pt:tak.sl"$
  74. off syslisp;
  75. procedure UndefinedFunctionAux;
  76. <<Putc Char U;
  77. Putc Char !n;
  78. Putc Char !d;
  79. Putc Char !e;
  80. Putc Char !f;
  81. Putc Char Blank;
  82. Putint UndefnCode!*;
  83. Terpri();
  84. Quit;>>;
  85. end;