File r37/lisp/csl/html/r37_0273.html artifact 2a59f16dd1 part of check-in 955d0a90a7



<A NAME=COMP>

<TITLE>COMP</TITLE></A>
<b><a href=r37_idx.html>INDEX</a></b><p><p>



<B>COMP</B> _ _ _  _ _ _  _ _ _  _ _ _ <B>switch</B><P>
<P>
 
 <P>
<P>
When <em>comp</em> is on, any succeeding function definitions are compiled 
into a faster-running form. Default is <em>off</em>. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<P><PRE><TT></TT></PRE><P>The following procedure finds Fibonacci numbers recurs
ively. 
Create a new file ``refib&quot; in your current directory with the following 
lines in it:<P><PRE><TT> 

procedure refib(n);
   if fixp n and n &gt;= 0 then
     if n &lt;= 1 then 1
       else refib(n-1) + refib(n-2)
    else rederr &quot;nonnegative integer only&quot;;

end;

</TT></PRE><P>Now load REDUCE and run the following:<P><PRE><TT>

on time; 

  Time: 100 ms 



in &quot;refib&quot;$ 

  Time: 0 ms 



 

  REFIB 



 

  Time: 260 ms 



 

  Time: 20 ms 



refib(80); 

  37889062373143906 



 

  Time: 14840 ms 



on comp; 

  Time: 80 ms 



in &quot;refib&quot;$ 

  Time: 20 ms 



 

  REFIB 



 

  Time: 640 ms 



refib(80); 

  37889062373143906 



 

  Time: 10940 ms

</TT></PRE><P> 
<P>
<P>
Note that the compiled procedure runs faster. Your time messages will 
differ depending upon which system you have. Compiled functions remain so 
for the duration of the REDUCE session, and are then lost. They must be 
recompiled if wanted in another session. With the switch 
<A HREF=r37_0333.html>time</A> on 
as shown above, the CPU time used in executing the command is returned in 
milliseconds. Be careful not to leave <em>comp</em> on unless you want it, 
as it makes the processing of procedures much slower. 
<P>
<P>
<P>
<P>


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]