File r37/lisp/csl/html/r37_0277.html artifact c405fd9bbb part of check-in 3c4d7b69af



<A NAME=DEFN>

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



<B>DEFN</B> _ _ _  _ _ _  _ _ _  _ _ _ <B>switch</B><P>
<P>
 
 <P>
<P>
When the switch <em>defn</em> is on, the Standard Lisp equivalent of the 
input statement or procedure is printed, but not evaluated. Default is 
<em>off</em>. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<P><PRE><TT>

on defn; 


17/3; 

  (AEVAL (LIST 'QUOTIENT 17 3)) 



df(sin(x),x,2);          
 

  (AEVAL (LIST 'DF (LIST 'SIN 'X) 'X 2)) 


procedure coshval(a);
   begin scalar g;
      g := (exp(a) + exp(-a))/2;
      return g
   end;
 

  (AEVAL 
    (PROGN 
      (FLAG '(COSHVAL) 'OPFN) 
      (DE COSHVAL (A) 
        (PROG (G) 
          (SETQ G 
            (AEVAL 
               (LIST 
                  'QUOTIENT 
                  (LIST 
                     'PLUS 
                     (LIST 'EXP A) 
                     (LIST 'EXP (LIST 'MINUS A))) 
                  2))) 
         (RETURN G)))) ) 



coshval(1); 

  (AEVAL (LIST 'COSHVAL 1)) 



off defn; 


coshval(1); 

  Declare COSHVAL operator? (Y or N) 



n 

procedure coshval(a);
   begin scalar g;
      g := (exp(a) + exp(-a))/2;
      return g
   end;
 

  COSHVAL 



on rounded; 


coshval(1); 

  1.54308063482

</TT></PRE><P>The above function <em>coshval</em> finds the hyperbolic cosine (c
osh) of its 
argument. When <em>defn</em> is on, you can see the Standard Lisp equivalent 
of the function, but it is not entered into the system as shown by the 
message <em>Declare COSHVAL operator?</em>. It must be reentered with 
<em>defn</em> off to be recognized. This procedure is used as an example; a 
more efficient procedure would eliminate the unnecessary local variable 
with 
<P><PRE><TT>
      procedure coshval(a);
         (exp(a) + exp(-a))/2;
</TT></PRE><P><P>
<P>
<P>
<P>


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