Changeset 6f2edc in git for Singular/LIB/general.lib


Ignore:
Timestamp:
Apr 28, 1997, 9:27:25 PM (26 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
8c5a578cc8481c8a133a58030c4c4c8227d82bb1
Parents:
6d09c564c80f079b501f7187cf6984d040603849
Message:
Mon Apr 28 21:00:07 1997  Olaf Bachmann
<obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>

     * dunno why I am committing these libs -- have not modified any
       of them


git-svn-id: file:///usr/local/Singular/svn/trunk@205 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/general.lib

    r6d09c56 r6f2edc  
    1 // $Id: general.lib,v 1.1.1.1 1997-04-25 15:13:26 obachman Exp $
     1// $Id: general.lib,v 1.2 1997-04-28 19:27:17 obachman Exp $
    22//system("random",787422842);
    33//(GMG, last modified 22.06.96)
     
    2020 sum(vector/id/..[,v]); add components of vector/ideal/...[with indices v]
    2121           (parameters in square brackets [] are optional)
    22 
     22 wich(command);         searches for command and returns absolute
     23                        path, if found
    2324LIB "inout.lib";
    2425///////////////////////////////////////////////////////////////////////////////
     
    187188proc killall
    188189USAGE:   killall(); (no parameter)
    189          killall("proc");
     190         killall("type_name");
     191         killall("not", "type_name");
    190192COMPUTE: killall(); kills all user-defined variables but not loaded procedures
    191          killall("proc"); kills all loaded procedures
     193         killall("type_name"); kills all user-defined variables, of type "type_name"
     194         killall("not", "type_name"); kills all user-defined
     195         variables, except those of type "type_name" and except loaded procedures
    192196RETURN:  no return value
    193197NOTE:    killall should never be used inside a procedure
     
    201205         if( L[joni]!="LIB" and typeof(`L[joni]`)!="proc" ) { kill `L[joni]`; }
    202206      }
    203       return();
    204    }
    205    if( #[1] == "proc" )
    206    {
    207       for ( joni=size(L); joni>0; joni-- )
    208       {
    209          if( L[joni]=="LIB" or typeof(`L[joni]`)=="proc" ) { kill `L[joni]`; }
    210       }
    211    }
    212 }
    213 example
    214 { "EXAMPLE:"; echo = 2;
    215    ring rtest; ideal i=x,y,z; number n=37; string str="hi";
    216    export rtest,i,n,str;     //this makes the local variables global
     207   }
     208   else
     209   {
     210     if( size(#)==1 )
     211     {
     212       if( #[1] == "proc" )
     213       {
     214          for ( joni=size(L); joni>0; joni-- )
     215          {
     216             if( L[joni]=="LIB" or typeof(`L[joni]`)=="proc" )
     217               { kill `L[joni]`; }
     218          }
     219       }
     220       else
     221       {
     222          for ( ; joni>2; joni-- )
     223          {
     224            if(typeof(`L[joni]`)==#[1] and L[joni]!="LIB" and typeof(`L[joni]`)!="proc") { kill `L[joni]`; }
     225          }
     226        }
     227     }
     228     else
     229     {
     230        for ( ; joni>2; joni-- )
     231        {
     232          if(typeof(`L[joni]`)!=#[2] and L[joni]!="LIB" and typeof(`L[joni]`)!="proc") { kill `L[joni]`; }
     233        }
     234     }
     235  }
     236  return();
     237}
     238example
     239{ "EXAMPLE:"; echo = 2;
     240   ring rtest; ideal i=x,y,z; number n=37; string str="hi"; int j = 3;
     241   export rtest,i,n,str,j;     //this makes the local variables global
    217242   listvar(all);
    218    killall();
     243   killall("string"); // kills all string variables
     244   listvar(all);
     245   killall("not", "int"); // kills all variables except int's (and procs)
     246   listvar(all);
     247   killall(); // kills all vars except loaded procs
    219248   listvar(all);
    220249}
     
    590619}
    591620///////////////////////////////////////////////////////////////////////////////
     621
     622proc which (command)
     623USAGE:    which(command); command = string expression
     624RETURN:   Absolute pathname of command, if found in search path.
     625          Empty string, otherwise.
     626NOTE:     Based on the Unix command 'which'.
     627EXAMPLE:  example which; shows an example
     628{
     629   int rs;
     630   int i;
     631   string fn = "/tmp/which_" + string(system("pid"));
     632   string pn;
     633   if( typeof(command) != "string")
     634   {
     635        return pn;
     636   }
     637   i = system("sh", "which " + command + " > " + fn);
     638   pn = read(fn);
     639   pn[size(pn)] = "";
     640   i = 1;
     641   while ((pn[i] != " ") and (pn[i] != ""))
     642   {
     643     i = i+1;
     644   }
     645   if (pn[i] == " ") {pn[i] = "";}
     646   rs = system("sh", "ls " + pn + " > " + fn + " 2>&1 ");
     647   i = system("sh", "rm " + fn);
     648   if (rs == 0) {return (pn);}
     649   else
     650   {
     651     print (command + " not found ");
     652     return ("");
     653   }
     654}
     655example
     656{  "EXAMPLE:"; echo = 2;
     657    which("Singular");
     658}
     659///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.