home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / RLaB 1.18c / help / local < prev    next >
Encoding:
Text File  |  1994-10-08  |  1.2 KB  |  40 lines  |  [TEXT/RLAB]

  1. local
  2.  
  3. Syntax:    local ( VAR1 , VAR2 , VAR3, ... )
  4.  
  5. Description:
  6.  
  7.     The local statement forces a function to resolve specified
  8.     variable reference within the function itself. Each local
  9.     variable is initialized UNDEFINED, and is destroyed after
  10.     execution leaves the function. Each time execution enters the
  11.     function, the local variables are re-initialized.
  12.  
  13.     Declaring argument variables local copies the value of the
  14.     argument variable into the local variable of the same
  15.     name. The argument variable is not accessible while function
  16.     is executing. In essence, this procedure forces arguments to
  17.     be passed by value.
  18.  
  19.     For example:
  20.  
  21.     mgs = function(A)
  22.     {
  23.       local (A)
  24.       m = A.nr;  n = A.nc;
  25.       for(k in 1:n)
  26.         {
  27.           r[k;k] = norm( A[1:m;k], "2");
  28.           q[1:m;k] = A[1:m;k]/r[k;k];
  29.           for(j in k+1:n)
  30.         {
  31.           r[k;j] = q[1:m;k]' * A[1:m;j];
  32.               A[1:m;j] = A[1:m;j] - q[1:m;k] * r[k;j];
  33.             }
  34.          }
  35.       return << q = q; r = r >>;
  36.     };
  37.  
  38.  
  39.     The function `mgs' uses the local statement to forces
  40.     pass-by-va