Changeset 6f2edc in git for Singular/LIB/general.lib
- Timestamp:
- Apr 28, 1997, 9:27:25 PM (26 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 8c5a578cc8481c8a133a58030c4c4c8227d82bb1
- Parents:
- 6d09c564c80f079b501f7187cf6984d040603849
- 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:26obachman Exp $1 // $Id: general.lib,v 1.2 1997-04-28 19:27:17 obachman Exp $ 2 2 //system("random",787422842); 3 3 //(GMG, last modified 22.06.96) … … 20 20 sum(vector/id/..[,v]); add components of vector/ideal/...[with indices v] 21 21 (parameters in square brackets [] are optional) 22 22 wich(command); searches for command and returns absolute 23 path, if found 23 24 LIB "inout.lib"; 24 25 /////////////////////////////////////////////////////////////////////////////// … … 187 188 proc killall 188 189 USAGE: killall(); (no parameter) 189 killall("proc"); 190 killall("type_name"); 191 killall("not", "type_name"); 190 192 COMPUTE: 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 192 196 RETURN: no return value 193 197 NOTE: killall should never be used inside a procedure … … 201 205 if( L[joni]!="LIB" and typeof(`L[joni]`)!="proc" ) { kill `L[joni]`; } 202 206 } 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 } 238 example 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 217 242 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 219 248 listvar(all); 220 249 } … … 590 619 } 591 620 /////////////////////////////////////////////////////////////////////////////// 621 622 proc which (command) 623 USAGE: which(command); command = string expression 624 RETURN: Absolute pathname of command, if found in search path. 625 Empty string, otherwise. 626 NOTE: Based on the Unix command 'which'. 627 EXAMPLE: 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 } 655 example 656 { "EXAMPLE:"; echo = 2; 657 which("Singular"); 658 } 659 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.