rtrace.rlg 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. REDUCE Development Version, Mon Dec 21 14:11:25 1998 ...
  2. % rtrace.tst -- Test portable REDUCE tracing
  3. % Author: Francis J. Wright, 13 July 1998
  4. symbolic procedure test(a, b);
  5. begin scalar c, d;
  6. d := c := {a, b};
  7. return c
  8. end$
  9. rtr test;
  10. (test)
  11. getd 'test;
  12. (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
  13. )))
  14. prop 'test;
  15. ((rtraced!-procedure expr lambda (a b) (prog (c d) (setq d (setq c (list a b))) (
  16. return c))) (number!-of!-args . 2))
  17. test('a, 'b);
  18. Enter (1) test
  19. a: a$
  20. b: b$
  21. Leave (1) test = [a,b]$
  22. (a b)
  23. rtrst test;
  24. *** Trace mode of test changed.
  25. (test)
  26. getd 'test;
  27. (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
  28. )))
  29. prop 'test;
  30. ((rtraced!-setq . t) (rtraced!-procedure expr lambda (a b) (prog (c d) (
  31. rtraced!-setq d (rtraced!-setq c (list a b))) (return c))) (number!-of!-args . 2
  32. ))
  33. test('a, 'b);
  34. Enter (1) test
  35. a: a$
  36. b: b$
  37. d := c := [a,b]$
  38. Leave (1) test = [a,b]$
  39. (a b)
  40. unrtr test;
  41. (test)
  42. getd 'test;
  43. (expr lambda (a b) (prog (c d) (setq d (setq c (list a b))) (return c)))
  44. prop 'test;
  45. ((number!-of!-args . 2))
  46. test('a, 'b);
  47. (a b)
  48. algebraic procedure test(a, b);
  49. begin scalar c, d;
  50. d := c := {a, b};
  51. return c
  52. end$
  53. +++ test redefined
  54. rtr test;
  55. (test)
  56. getd 'test;
  57. (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
  58. )))
  59. prop 'test;
  60. ((rtraced!-procedure expr lambda (a b) (prog (c d) (setq d (setq c (aeval (list (
  61. quote list) a b)))) (return (aeval c)))) (opfn . t) (number!-of!-args . 2))
  62. test(a, b);
  63. Enter (1) test
  64. a: a$
  65. b: b$
  66. Leave (1) test = {a,b}$
  67. {a,b}
  68. rtrst test;
  69. *** Trace mode of test changed.
  70. (test)
  71. getd 'test;
  72. (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
  73. )))
  74. prop 'test;
  75. ((rtraced!-setq . t) (rtraced!-procedure expr lambda (a b) (prog (c d) (
  76. rtraced!-setq d (rtraced!-setq c (aeval (list (quote list) a b)))) (return (
  77. aeval c)))) (opfn . t) (number!-of!-args . 2))
  78. test(a, b);
  79. Enter (1) test
  80. a: a$
  81. b: b$
  82. d := c := {a,b}$
  83. Leave (1) test = {a,b}$
  84. {a,b}
  85. unrtr test;
  86. (test)
  87. getd 'test;
  88. (expr lambda (a b) (prog (c d) (setq d (setq c (aeval (list (quote list) a b))))
  89. (return (aeval c))))
  90. prop 'test;
  91. ((number!-of!-args . 2) (opfn . t))
  92. test(a, b);
  93. {a,b}
  94. algebraic procedure test(a, b);
  95. d := c := {a, b}$
  96. +++ test redefined
  97. rtr test;
  98. (test)
  99. getd 'test;
  100. (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
  101. )))
  102. prop 'test;
  103. ((rtraced!-procedure expr lambda (a b) (setk (quote d) (setk (quote c) (aeval (
  104. list (quote list) a b))))) (number!-of!-args . 2) (opfn . t))
  105. test(a, b);
  106. Enter (1) test
  107. a: a$
  108. b: b$
  109. Leave (1) test = {a,b}$
  110. {a,b}
  111. rtrst test;
  112. *** Trace mode of test changed.
  113. (test)
  114. getd 'test;
  115. (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
  116. )))
  117. prop 'test;
  118. ((rtraced!-setq . t) (rtraced!-procedure expr lambda (a b) (rtraced!-setk (quote
  119. d) (rtraced!-setk (quote c) (aeval (list (quote list) a b))))) (number!-of!-args
  120. . 2) (opfn . t))
  121. test(a, b);
  122. Enter (1) test
  123. a: a$
  124. b: b$
  125. c := {a,b}$
  126. d := {a,b}$
  127. Leave (1) test = {a,b}$
  128. {a,b}
  129. unrtr test;
  130. (test)
  131. getd 'test;
  132. (expr lambda (a b) (setk (quote d) (setk (quote c) (aeval (list (quote list) a b
  133. )))))
  134. prop 'test;
  135. ((number!-of!-args . 2) (opfn . t))
  136. test(a, b);
  137. {a,b}
  138. % Examples used in documentation (rtrace.tex):
  139. algebraic procedure power(x, n);
  140. if n = 0 then 1 else x*power(x, n-1)$
  141. rtr power;
  142. (power)
  143. power(x+1, 2);
  144. Enter (1) power
  145. x: x + 1$
  146. n: 2$
  147. Enter (2) power
  148. x: x + 1$
  149. n: 1$
  150. Enter (3) power
  151. x: x + 1$
  152. n: 0$
  153. Leave (3) power = 1$
  154. Leave (2) power = x + 1$
  155. Leave (1) power = x**2 + 2*x + 1$
  156. 2
  157. x + 2*x + 1
  158. off rtrace;
  159. power(x+1, 2);
  160. Enter (1) power
  161. x: (plus x 1)
  162. n: 2
  163. Enter (2) power
  164. x: (plus x 1)
  165. n: 1
  166. Enter (3) power
  167. x: (plus x 1)
  168. n: 0
  169. Leave (3) power = 1
  170. Leave (2) power = (!*sq ((((x . 1) . 1) . 1) . 1) t)
  171. Leave (1) power = (!*sq ((((x . 2) . 1) ((x . 1) . 2) . 1) . 1) t)
  172. 2
  173. x + 2*x + 1
  174. on rtrace;
  175. unrtr power;
  176. (power)
  177. rtr int;
  178. (simpint)
  179. unrtr int;
  180. (simpint)
  181. procedure fold u;
  182. for each x in u sum x$
  183. rtrst fold;
  184. (fold)
  185. fold {z, z*y, y};
  186. Enter (1) fold
  187. u: {z,y*z,y}$
  188. x := [z,y*z,y]$
  189. g0 := 0$
  190. g0 := z$
  191. x := [y*z,y]$
  192. g0 := z*(y + 1)$
  193. x := [y]$
  194. g0 := y*z + y + z$
  195. x := []$
  196. Leave (1) fold = y*z + y + z$
  197. y*z + y + z
  198. unrtrst fold;
  199. (fold)
  200. trigrules := {sin(~x)^2 => 1 - cos(x)^2};
  201. 2 2
  202. trigrules := {sin(~x) => 1 - cos(x) }
  203. let trigrules;
  204. trrl trigrules;
  205. 1 - sin(x)^2;
  206. Rule trigrules.1: sin(x)**2 => 1 - cos(x)**2$
  207. 2
  208. cos(x)
  209. untrrl trigrules;
  210. trrl sin;
  211. 1 - sin(x)^2;
  212. Rule sin.23: sin(x)**2 => 1 - cos(x)**2$
  213. 2
  214. cos(x)
  215. untrrl sin;
  216. clearrules trigrules;
  217. trrlid trigrules;
  218. 1 - sin(x)^2 where trigrules;
  219. Rule trigrules.1: sin(x)**2 => 1 - cos(x)**2$
  220. 2
  221. cos(x)
  222. untrrlid trigrules;
  223. end;
  224. Time for test: 120 ms