123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- REDUCE Development Version, Mon Dec 21 14:11:25 1998 ...
- % rtrace.tst -- Test portable REDUCE tracing
- % Author: Francis J. Wright, 13 July 1998
- symbolic procedure test(a, b);
- begin scalar c, d;
- d := c := {a, b};
- return c
- end$
- rtr test;
- (test)
- getd 'test;
- (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
- )))
- prop 'test;
- ((rtraced!-procedure expr lambda (a b) (prog (c d) (setq d (setq c (list a b))) (
- return c))) (number!-of!-args . 2))
- test('a, 'b);
- Enter (1) test
- a: a$
- b: b$
- Leave (1) test = [a,b]$
- (a b)
- rtrst test;
- *** Trace mode of test changed.
- (test)
- getd 'test;
- (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
- )))
- prop 'test;
- ((rtraced!-setq . t) (rtraced!-procedure expr lambda (a b) (prog (c d) (
- rtraced!-setq d (rtraced!-setq c (list a b))) (return c))) (number!-of!-args . 2
- ))
- test('a, 'b);
- Enter (1) test
- a: a$
- b: b$
- d := c := [a,b]$
- Leave (1) test = [a,b]$
- (a b)
- unrtr test;
- (test)
- getd 'test;
- (expr lambda (a b) (prog (c d) (setq d (setq c (list a b))) (return c)))
- prop 'test;
- ((number!-of!-args . 2))
- test('a, 'b);
- (a b)
- algebraic procedure test(a, b);
- begin scalar c, d;
- d := c := {a, b};
- return c
- end$
- +++ test redefined
- rtr test;
- (test)
- getd 'test;
- (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
- )))
- prop 'test;
- ((rtraced!-procedure expr lambda (a b) (prog (c d) (setq d (setq c (aeval (list (
- quote list) a b)))) (return (aeval c)))) (opfn . t) (number!-of!-args . 2))
- test(a, b);
- Enter (1) test
- a: a$
- b: b$
- Leave (1) test = {a,b}$
- {a,b}
- rtrst test;
- *** Trace mode of test changed.
- (test)
- getd 'test;
- (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
- )))
- prop 'test;
- ((rtraced!-setq . t) (rtraced!-procedure expr lambda (a b) (prog (c d) (
- rtraced!-setq d (rtraced!-setq c (aeval (list (quote list) a b)))) (return (
- aeval c)))) (opfn . t) (number!-of!-args . 2))
- test(a, b);
- Enter (1) test
- a: a$
- b: b$
- d := c := {a,b}$
- Leave (1) test = {a,b}$
- {a,b}
- unrtr test;
- (test)
- getd 'test;
- (expr lambda (a b) (prog (c d) (setq d (setq c (aeval (list (quote list) a b))))
- (return (aeval c))))
- prop 'test;
- ((number!-of!-args . 2) (opfn . t))
- test(a, b);
- {a,b}
- algebraic procedure test(a, b);
- d := c := {a, b}$
- +++ test redefined
- rtr test;
- (test)
- getd 'test;
- (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
- )))
- prop 'test;
- ((rtraced!-procedure expr lambda (a b) (setk (quote d) (setk (quote c) (aeval (
- list (quote list) a b))))) (number!-of!-args . 2) (opfn . t))
- test(a, b);
- Enter (1) test
- a: a$
- b: b$
- Leave (1) test = {a,b}$
- {a,b}
- rtrst test;
- *** Trace mode of test changed.
- (test)
- getd 'test;
- (expr lambda (a b) (run!-rtraced!-procedure (quote test) (quote (a b)) (list a b
- )))
- prop 'test;
- ((rtraced!-setq . t) (rtraced!-procedure expr lambda (a b) (rtraced!-setk (quote
- d) (rtraced!-setk (quote c) (aeval (list (quote list) a b))))) (number!-of!-args
- . 2) (opfn . t))
- test(a, b);
- Enter (1) test
- a: a$
- b: b$
- c := {a,b}$
- d := {a,b}$
- Leave (1) test = {a,b}$
- {a,b}
- unrtr test;
- (test)
- getd 'test;
- (expr lambda (a b) (setk (quote d) (setk (quote c) (aeval (list (quote list) a b
- )))))
- prop 'test;
- ((number!-of!-args . 2) (opfn . t))
- test(a, b);
- {a,b}
- % Examples used in documentation (rtrace.tex):
- algebraic procedure power(x, n);
- if n = 0 then 1 else x*power(x, n-1)$
- rtr power;
- (power)
- power(x+1, 2);
- Enter (1) power
- x: x + 1$
- n: 2$
- Enter (2) power
- x: x + 1$
- n: 1$
- Enter (3) power
- x: x + 1$
- n: 0$
- Leave (3) power = 1$
- Leave (2) power = x + 1$
- Leave (1) power = x**2 + 2*x + 1$
- 2
- x + 2*x + 1
- off rtrace;
- power(x+1, 2);
- Enter (1) power
- x: (plus x 1)
- n: 2
- Enter (2) power
- x: (plus x 1)
- n: 1
- Enter (3) power
- x: (plus x 1)
- n: 0
- Leave (3) power = 1
- Leave (2) power = (!*sq ((((x . 1) . 1) . 1) . 1) t)
- Leave (1) power = (!*sq ((((x . 2) . 1) ((x . 1) . 2) . 1) . 1) t)
- 2
- x + 2*x + 1
- on rtrace;
- unrtr power;
- (power)
- rtr int;
- (simpint)
- unrtr int;
- (simpint)
- procedure fold u;
- for each x in u sum x$
- rtrst fold;
- (fold)
- fold {z, z*y, y};
- Enter (1) fold
- u: {z,y*z,y}$
- x := [z,y*z,y]$
- g0 := 0$
- g0 := z$
- x := [y*z,y]$
- g0 := z*(y + 1)$
- x := [y]$
- g0 := y*z + y + z$
- x := []$
- Leave (1) fold = y*z + y + z$
- y*z + y + z
- unrtrst fold;
- (fold)
- trigrules := {sin(~x)^2 => 1 - cos(x)^2};
- 2 2
- trigrules := {sin(~x) => 1 - cos(x) }
- let trigrules;
- trrl trigrules;
- 1 - sin(x)^2;
- Rule trigrules.1: sin(x)**2 => 1 - cos(x)**2$
- 2
- cos(x)
- untrrl trigrules;
- trrl sin;
- 1 - sin(x)^2;
- Rule sin.23: sin(x)**2 => 1 - cos(x)**2$
- 2
- cos(x)
- untrrl sin;
- clearrules trigrules;
- trrlid trigrules;
- 1 - sin(x)^2 where trigrules;
- Rule trigrules.1: sin(x)**2 => 1 - cos(x)**2$
- 2
- cos(x)
- untrrlid trigrules;
- end;
- Time for test: 120 ms
|