Changeset a25fbca in git for Singular/LIB/inout.lib
- Timestamp:
- Feb 9, 2010, 7:34:44 PM (14 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- bf3a67ebcb83abf41b02b083b19bd29eb4000fe6
- Parents:
- 6c939eebfd221f2512b1e27d158d1b5457206987
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/inout.lib
r6c939e ra25fbca 15 15 split(string,n); split given string into lines of length n 16 16 tab(n); string of n space tabs 17 writelist(...); write a list into a file and keep the list structure18 17 pause([prompt]); stop the computation until user input 19 18 (parameters in square brackets [] are optional) … … 665 664 /////////////////////////////////////////////////////////////////////////////// 666 665 667 proc writelist (string fil, string nam, list L)668 "USAGE: writelist(file,name,L); file,name strings (file-name, list-name),669 L a list.670 CREATE: a file with name `file`, write the content of the list L into it and671 call the list `name`, keeping the list structure672 RETURN: no return value673 NOTE: The syntax of writelist is similar to the syntax of the674 write command of @sc{Singular} which does not manage lists properly.675 If (file,name) = (\"listfile\",\"L1\"), writelist creates (resp.676 appends if listfile exists) a file with name listfile and stores677 there the list L under the name L1. The @sc{Singular} command678 @code{execute(read(\"listfile\"))}; assigns the content of L (stored in679 listfile) to a list L1.680 @* On a UNIX system, write(\">file\",...) overwrites an existing file681 `file` while write(\"file\",...) and write(\">>file\",...) append.682 EXAMPLE: example writelist; shows an example683 "684 {685 int i;686 write(fil,"list "+nam+";");687 if( fil[1]==">" ) { fil=fil[2..size(fil)]; }688 if( fil[1]==">" ) { fil=fil[2..size(fil)]; }689 for( i=1;i<=size(L);i=i+1 )690 {691 if (typeof(L[i]) == "intmat")692 {693 write(fil," "+nam+"["+string(i)+"]="+694 "intmat(intvec("+string(L[i])+695 "),"+string(nrows(L[i]))+","+string(ncols(L[i]))+");");696 }697 else698 {699 if ( typeof(L[i])== "matrix")700 {701 write(fil," "+nam+"["+string(i)+"]="+702 "matrix(ideal("+string(L[i])+703 "),"+string(nrows(L[i]))+","+string(ncols(L[i]))+");");704 }705 else706 {707 write(fil," "+nam+"["+string(i)+"]="+typeof(L[i])+"(",string(L[i])+");");708 }709 }710 }711 return();712 }713 example714 { "EXAMPLE:"; echo = 2;715 ring r;716 ideal i=x,y,z;717 list k="Hi",nameof(basering),i,37;718 writelist("zumSpass","lustig",k);719 read("zumSpass");720 list L=res(i,0); //resolution of the ideal i721 writelist("res_list","res-name",L); "";722 read("res_list");723 // execute(read("res_list")); would create a list with name res-name,724 // which is the resolution of i (the same content as L)725 726 system("sh","/bin/rm res_list zumSpass");727 // Under UNIX, this removes the files 'res_list' and 'zumSpass'728 // Type help system; to get more information about the shell escape729 // If your operating system does not accept the shell escape, you730 // must remove the just created files 'zumSpass' and 'res_list' directly731 }732 ///////////////////////////////////////////////////////////////////////////////733 734 666 proc pause(list #) 735 667 "USAGE: pause([ prompt ]) prompt string
Note: See TracChangeset
for help on using the changeset viewer.