Artifact b0a618f72657f192652bdc2b7d2294d7529079246644d4d5b103eb0d94a31c6a:
- Executable file
r37/doc/manual/rememb.tex
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1109) [annotate] [blame] [check-ins using] [more...]
- Executable file
r38/doc/manual/rememb.tex
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1109) [annotate] [blame] [check-ins using]
- Executable file
r38/lisp/csl/r38.doc/rememb.tex
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1109) [annotate] [blame] [check-ins using]
\section{REMEMBER Statement}\ttindex{REMEMBER} Setting the remember option for an algebraic procedure by \begin{verbatim} REMEMBER (PROCNAME:procedure); \end{verbatim} saves all intermediate results of such procedure evaluations, including recursive calls. Subsequent calls to the procedure can then be determined from the saved results, and thus the number of evaluations (or the complexity) can be reduced. This mode of evalation costs extra memory, of course. In addition, the procedure must be free of side--effects. The following examples show the effect of the remember statement on two well--known examples. \begin{samepage} \begin{verbatim} procedure H(n); % Hofstadter's function if numberp n then << cnn := cnn +1; % counts the calls if n < 3 then 1 else H(n-H(n-1))+H(n-H(n-2))>>; remember h; > << cnn := 0; H(100); cnn>>; 100 % H has been called 100 times only. procedure A(m,n); % Ackermann function if m=0 then n+1 else if n=0 then A(m-1,1) else A(m-1,A(m,n-1)); remember a; A(3,3); \end{verbatim} \end{samepage}