This file is indexed.

/usr/share/singular/LIB/inout.lib is in singular-data 4.0.3+ds-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
//////////////////////////////////////////////////////////////////////////////
version="version inout.lib 4.0.0.0 Jun_2013 "; // $Id: f30ec30553869bbe596da3bd3649a0494e59cc09 $
category="General purpose";
info="
LIBRARY:  inout.lib     Printing and Manipulating In- and Output

PROCEDURES:
 allprint(list);        print list if ALLprint is defined, with pause if >0
 lprint(poly/...[,n]);  display poly/... fitting to pagewidth [size n]
 pmat(matrix[,n]);      print form-matrix [first n chars of each colum]
 rMacaulay(string);     read Macaulay_1 output and return its @sc{Singular} format
 show(any);             display any object in a compact format
 showrecursive(id,p);   display id recursively with respect to variables in p
 split(string,n);       split given string into lines of length n
 tab(n);                string of n space tabs
 pause([prompt]);       stop the computation until user input
           (parameters in square brackets [] are optional)
";

///////////////////////////////////////////////////////////////////////////////

proc allprint (list #)
"USAGE:   allprint(L);  L list
DISPLAY: prints L[1], L[2], ... if an integer with name ALLprint is defined.
@*       makes \"pause\",   if ALLprint > 0
RETURN:  no return value
EXAMPLE: example allprint; shows an example
"
{
   if( defined(ALLprint) )
   {
      int i;
      for( i=1; i<=size(#); i=i+1 ) { print(#[i]); }
      if( ALLprint >0 ) { pause(); }
   }
   return();
}
example
{ "EXAMPLE:"; echo = 2;
   ring S;
   matrix M=matrix(freemodule(2),3,3);
   int ALLprint; export ALLprint;
   allprint("M =",M);
   kill ALLprint;
}
///////////////////////////////////////////////////////////////////////////////

proc lprint
"USAGE:   lprint(id[,n]);  id poly/ideal/vector/module/matrix, n integer
RETURN:  string of id in a format fitting into lines of size n, such that no
         monomial gets destroyed, i.e. the new line starts with + or -;
         (default: n = pagewidth).
NOTE:    id is printed columnwise, each column separated by a blank line;
         hence lprint(transpose(id)); displays a matrix id in a format which
         can be used as input.
EXAMPLE: example lprint; shows an example
"
{
   if (size(#)==1) { int n = pagewidth-3; }
   else {int n = #[2]-3; }
   matrix M = matrix(#[1]);
   poly p,h,L; string s1,s,S; int jj,ii,a;
   for (jj=1; jj<=ncols(M); jj=jj+1)
   {
      for (ii=1; ii<=nrows(M); ii=ii+1)
      {
         a=2;
         if (a+size(string(M[ii,jj])) <= n) {s = "  "+string(M[ii,jj]);}
         else
         {
            h = lead(M[ii,jj]); p = M[ii,jj] - h; L = lead(p);
            while (p != 0)
            {
               if (a+size(string(h+L)) > n)
               {
                  s = string(h);
                  if (a != 0) { s = "  "+s; }
                  if (a == 0 and s[1] != "-") { s = "+" + s; }
                  a=0; h=0; S=S+newline+s;
               }
               h = h + L; p = p - L; L = lead(p);
            }
            s = string(h);
            if (a == 0 and s[1] != "-") { s = "+" + s; }
         }
         if (ii != nrows(M)) { s = s+","; S=S+newline+s; }
         else
         {
            if (jj != ncols(M)) { s = s+","; S=S+newline+s+newline;}
            else { S=S+newline+s; }
         }
      }
   }
   return(S[2,size(S)-1]);
}
example
{ "EXAMPLE:"; echo = 2;
   ring r= 0,(x,y,z),ds;
   poly f=((x+y)*(x-y)*(x+z)*(y+z)^2);
   lprint(f,40);
   module m = [f*(x-y)],[0,f*(x-y)];
   string s=lprint(m); s;"";
   execute("matrix M[2][2]="+s+";");      //use the string s as input
   module m1 = transpose(M);              //should be the same as m
   print(matrix(m)-matrix(m1));
}
///////////////////////////////////////////////////////////////////////////////

proc pmat (matrix m, list #)
"USAGE:   pmat(M[,n]);  M matrix, n integer
RETURN: A string representing M in array format if it fits into
        pagewidth; if n is given, only the first n characters of
        each column are shown (n>1 required), where a truncation
        of a column is indicated by two dots (\'..\')
EXAMPLE: example pmat; shows an example
"
{
//------------- main case: input is a matrix, no second argument---------------
   string OUT = "";
   if ( size(#)==0)
   {
      int elems,mlen,slen,c,r;
   //-------------- count maximal size of each column, and sum up -------------
      for ( c=1; c<=ncols(m); c=c+1)
      {  int len(c);
         for (r=1; r<=nrows(m); r=r+1)
         {
            elems = elems+1;
            string s(elems) = string(m[r,c])+",";
            slen = size(s(elems));
            if ( slen>len(c) ) { len(c) = slen; }
         }
         mlen = mlen+len(c);
      }
   //---------------------- print all - except last - rows --------------------
      string aus; string sep = " ";
      if (mlen >= pagewidth) { sep = newline; }
      for (r=1; r<nrows(m); r=r+1)
      {  elems = r; aus = "";
         for (c=1; c<=ncols(m); c=c+1)
         {
            aus = aus + s(elems)[1,len(c)] + sep;
            elems = elems + nrows(m);
         }
         OUT=OUT+aus+newline;
      }
   //--------------- print last row (no comma after last entry) ---------------
      aus = ""; elems = nrows(m);
      for (c=1; c<ncols(m); c=c+1)
      {
         aus = aus + s(elems)[1,len(c)] + sep;
         elems = elems + nrows(m);
      }
      aus = aus + string(m[nrows(m),ncols(m)]);
      OUT=OUT+aus;  return(OUT);
   }
//---------- second case: second argument is given and of type int ------------
   if ( typeof(#[1])=="int" and #[1]>1)
   {  string aus,tmp; int c,r;
   //---------------------- print all - except last - rows --------------------
      for ( r=1; r<nrows(m); r=r+1)
      {  aus = "";
         for (c=1; c<=ncols(m); c=c+1)
         {
            tmp=string(m[r,c]);
            if (size(tmp)>#[1])
            { tmp[#[1]-1]=".";
              tmp[#[1]]  =".";
              aus=aus+tmp[1,#[1]]+", ";
            }
            else
            { tmp=tmp+",";
              aus=aus+tmp[1,#[1]+1]+" ";
            }
         }
         OUT=OUT+aus+newline;
      }
   //--------------- print last row (no comma after last entry) ---------------
      aus = "";
      for (c=1; c<ncols(m); c=c+1)
      { tmp=string(m[r,c]);
        if (size(tmp)>#[1])
        { tmp[#[1]-1]=".";
          tmp[#[1]]  =".";
          aus=aus+tmp[1,#[1]]+", ";
        }
        else
        { tmp=tmp+",";
          aus=aus+tmp[1,#[1]+1]+" ";
        }
      }
      tmp=string(m[nrows(m),ncols(m)]);
      if (size(tmp)>#[1])
      { tmp[#[1]-1]=".";
        tmp[#[1]]  =".";
      }
      aus = aus + tmp[1,#[1]];
      OUT=OUT+aus;  return(OUT);
   }
}
example
{  "EXAMPLE:"; echo = 2;
   ring r=0,(x,y,z),ls;
   ideal i= x,z+3y,x+y,z;
   matrix m[3][3]=i^2;
   pmat(m);
   pmat(m,5);
}
///////////////////////////////////////////////////////////////////////////////

proc rMacaulay
"USAGE:   rMacaulay(s[,n]);  s string, n integer
RETURN:  A string denoting a file which should be readable by Singular
         and it should be produced by Macaulay Classic.
         If a second argument is present the first
         n lines of the file are deleted (which is useful if the file was
         produced e.g. by the putstd command of Macaulay).
NOTE:    This does not always work with 'cut and paste' since the character
         \ is treated differently
EXAMPLE: example rMacaulay; shows an example
"
{
   int n;
   if( size(#)==2 ) { n=#[2]; }
   string s0 = #[1];
//------------------------ delete first n=#[2] lines --------------------------
   int ii=find(s0,newline); int jj;
   for ( jj=1; jj<=n; jj=jj+1)
   {
      s0 = s0[ii+1,size(s0)-ii];
      ii = find(s0,newline);
   }
//--------------- delete blanks and 'newline' at start and end ----------------
   ii = 1;
   while( s0[ii]==" " or s0[ii]==newline ) { ii=ii+1; }
   s0 = s0[ii,size(s0)-ii+1]; ii = size(s0);
   while ( s0[ii]==" " or s0[ii]==newline) { ii=ii-1; }
   s0 = s0[1,ii];
//------------------------- make each line a string ---------------------------
   ii = find(s0,newline); jj=0; int kk;
   while( ii!=0 )
   {  jj = jj+1;  kk = ii+1;
      while( s0[kk]==" " or s0[kk]==newline ) {  kk=kk+1; }
      string s(jj) = s0[1,ii-1];
      s0 = s0[kk,size(s0)-kk+1];
      ii = find(s0,newline);
   }
   jj=jj+1;
   string s(jj) = s0;
//------------ delete blanks and \ at end of each string and add , ------------
   for( ii=1; ii<=jj; ii=ii+1 )
   {  kk = 1;
      while( s(ii)[kk]==" " ) { kk=kk+1; }
      s(ii) = s(ii)[kk,size(s(ii))-kk+1];
      kk = size(s(ii));
      while( s(ii)[kk]==" " or s(ii)[kk]=="\\" or s(ii)[kk]==newline )
         {  kk = kk-1; }
      s(ii) = s(ii)[1,kk]+","+newline;
   }
//------------------------ replace blanks by , and add up ---------------------
   int ll; s0 = ""; string s1,s2;
   for( ii=1; ii<=jj; ii=ii+1 )
   {
      s1 = ""; s2 = s(ii);
      kk = find(s(ii)," "); ll=kk+1;
      while( kk!=0 )
      {
         while( s2[ll]==" ") { ll=ll+1; }
         if( kk!=1 ) { s1=s1+s2[1,kk-1]+","+s2[kk+1,ll-kk]; }
         if( kk==1 ) { s1 = s1+","+s2[kk+1,ll-kk]; }
         s2 = s2[ll+1,size(s2)-ll];
         kk = find(s2," "); ll=kk+1;
      }
      s(ii) = s1+s2; s0 = s0+s(ii);
   }
//---------------------------- replace [] by () -------------------------------
   s1 = ""; s2 = s0;
   ii = find(s2,"[");
   while( ii!=0 )
   {
      s0 = s0[1,ii-1]+"("+s0[ii+1,size(s0)-ii];
      if( ii>2 )
      {
         if(s0[ii-2]!="+" and s0[ii-2]!="-" and s0[ii-2]!="," and s0[ii-2]!=newline)
         {
            s0 = s0[1,ii-2]+"*"+s0[ii-1,size(s0)-ii+2];
         }
      }
      ii = find(s0,"[");
   }
   jj = find(s0,"]");
   while ( jj!=0 )
   {
      s0 = s0[1,jj-1]+")"+s0[jj+1,size(s0)-jj];
      if(s0[jj+1]!="+"and s0[jj+1]!="-" and s0[jj+1]!="," and s0[jj+1]!="*")
         { s0 = s0[1,jj] + "^" + s0[jj+1,size(s0)-jj]; }
      jj = find(s0,"]");
   }
   s0 = s0[1,size(s0)-2];
   return(s0);
}
example
{  "EXAMPLE:"; echo = 2;
   // Assume there exists a file 'Macid' with the following ideal in
   // Macaulay format:"
   // x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2] \
   //     -4/71x[0]x[1]x[2]
   // Read this file into Singular and assign it to the string s1 by:
   // string s1 = read("Macid");
   // This is equivalent to";
   string s1 =
   "x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2]-4/71x[0]x[1]x[2]";
   rMacaulay(s1);
   // You may wish to assign s1 to a Singular ideal id:
   string sid = "ideal id =",rMacaulay(s1),";";
   ring r = 0,x(0..3),dp;
   execute(sid);
   id; "";
   // Now treat a matrix in Macaulay format. Using the execute
   // command, this could be assinged to a Singular matrix as above.
   string s2 = "
   0  0  0  0  0
   a3 0  0  0  0
   0  b3 0  0  0
   0  0  c3 0  0
   0  0  0  d3 0
   0  0  0  0  e3 ";
   rMacaulay(s2);
}

///////////////////////////////////////////////////////////////////////////////

proc show (def @@id, list #)
"USAGE:   show(id);   id any object of basering or of type ring/qring
@*       show(R,s);  R=ring, s=string (s = name of an object belonging to R)
DISPLAY: display id/s in a compact format together with some information
RETURN:  no return value
NOTE:    objects of type string, int, intvec, intmat belong to any ring.
         id may be a ring or a qring. In this case the minimal polynomial is
         displayed, and, for a qring, also the defining ideal.
         id may be of type list but the list must not contain a ring.
@*       show(R,s) does not work inside a procedure!
EXAMPLE: example show; shows an example
"
{
//------------- use funny names in order to avoid name conflicts --------------
   int @li@, @ii;
   string @s@,@@s;
   int @short@=short; short=1;
//----------------------------- check syntax ----------------------------------
   if( size(#)!= 0 )
   {
      if( typeof(#[1])=="int" ) { @li@=#[1]; }
   }
   if ( typeof(@@id)!="list" )
   {
      if( size(#)==0 )
      {
          def @id@ = @@id;
      }
      if( size(#)==1 )
      {
         if( typeof(#[1])=="int" )
         {
             def @id@ = @@id;
         }
         if( typeof(#[1])=="string" )
         {
            if( typeof(@@id)=="ring")
            {
               def @R@ = @@id;
               setring @R@;
               def @id@=`#[1]`;
            }
         }
      }
   }
//----------------------- case: @@id is of type list ----------------------------
   if ( typeof(@@id)=="list" )
   {
//      @@s = tab(@li@)+"// list, "+string(size(@@id))+" element(s):";
      @@s = tab((3*(voice-2)))+"// list, "+string(size(@@id))+" element(s):";
      @@s;
      for ( @ii=1; @ii<=size(@@id); @ii++ )
      {
         if( typeof(@@id[@ii])!="none" )
         {
            def @id(@ii) = @@id[@ii];
            tab(3*(voice-2))+"["+string(@ii)+"]:";
            //           show(@id(@ii),@li@+3*(voice-1));
            show(@id(@ii),3*(voice-1));
         }
         else
         {
            "["+string(@ii)+"]:";
            tab(@li@+2),"//",@@id[@ii];
         }
      }
      short=@short@; return();
    }
   if( defined(@id@)!=voice ) { "// wrong syntax, type help show;";  return();}
//-------------------- case: @id@ belongs to any ring -------------------------
   if( typeof(@id@)=="string" or typeof(@id@)=="int" or typeof(@id@)=="intvec"
       or typeof(@id@)=="intmat" or typeof(@id@)=="list" )
   {
      if( typeof(@id@)!="intmat" )
      {
         @@s = tab(@li@)+"// "+typeof(@id@)+", size "+string(size(@id@));
         @@s;
      }
      if( typeof(@id@)=="intmat" )
      {
         @@s = tab(@li@)+"// "+typeof(@id@)+", "+string(nrows(@id@))+" rows, "
               + string(ncols(@id@))+" columns";
         @@s;
      }
      @id@;
      short=@short@; return();
   }
//-------------------- case: @id@ belongs to basering -------------------------
   if( typeof(@id@)=="poly" or typeof(@id@)=="ideal" or typeof(@id@)=="matrix" )
   {
      @@s = tab(@li@)+"// "+ typeof(@id@);
      if( typeof(@id@)=="ideal" )
      {
         @@s=@@s + ", "+string(ncols(@id@))+" generator(s)";
         @@s;
         print(ideal(@id@));
      }
      if( typeof(@id@)=="poly" )
      {
         @@s=@@s + ", "+string(size(@id@))+" monomial(s)";
         @@s;
         print(poly(@id@));
      }
      if( typeof(@id@)=="matrix")
      {
         @@s=@@s + ", "+string(nrows(@id@))+"x"+string(ncols(@id@));
         @@s;
         print(matrix(@id@));
      }
      short=@short@; return();
   }
   if( typeof(@id@)=="vector" )
   {
      @@s = tab(@li@)+"// "+typeof(@id@);
      @@s;
      print(@id@);
      short=@short@; return();
   }
   if( typeof(@id@)=="module" )
   {
      @s@=", "+string(ncols(@id@))+" generator(s)";
      @@s = tab(@li@)+"// "+ typeof(@id@)+ @s@;
      @@s;
      int @n@;
      for( @n@=1; @n@<=ncols(@id@); @n@=@n@+1 ) { print(@id@[@n@]); }
      short=@short@; return();
   }
   if( typeof(@id@)=="number" or typeof(@id@)=="resolution" )
   {
      @@s = tab(@li@)+"// ", typeof(@id@);
      @@s;
      @id@; short=@short@; return();
   }
   if( typeof(@id@)=="map" )
   {
      def @map = @id@;
      @@s = tab(@li@)+"// i-th variable of preimage ring is mapped to @map[i]";
      @@s;
      if( size(#)==0 ) { type @map; }
      if( size(#)==1 )
      {
         if( typeof(#[1])=="int" )    { type @map; }
         if( typeof(#[1])=="string" ) { type `#[1]`; }
      }
      short=@short@; return();
   }
//---------------------- case: @id@ is a ring/qring ---------------------------
   if( typeof(@id@)=="ring" )
   {
      setring @id@;
      string s="("+charstr(@id@)+"),("+varstr(@id@)+"),("+ordstr(@id@)+");";
      if( typeof(@id@)=="ring" )
      {
         list na@me@s=names(@id@);
         @@s = tab(@li@)+"// ring:"; @@s,s;
         @@s = tab(@li@)+"// minpoly ="; @@s,minpoly;
         if (size(ideal(@id@))>0)
         {
           @@s = tab(@li@)+"// quotient ring from ideal:"; @@s;ideal(@id@);
         }
         kill @id@;
         "// objects belonging to this ring:";
         listvar(poly);listvar(ideal);
         listvar(vector);listvar(module);
         listvar(map);listvar(matrix);
         listvar(number);listvar(resolution);
         for(int names@i=1;names@i<=size(na@me@s);names@i++)
         {
           def @hi@lf@=`na@me@s[names@i]`;
           if ((typeof(@hi@lf@)!="poly") and
               (typeof(@hi@lf@)!="ideal") and
               (typeof(@hi@lf@)!="vector") and
               (typeof(@hi@lf@)!="module") and
               (typeof(@hi@lf@)!="map") and
               (typeof(@hi@lf@)!="matrix") and
               (typeof(@hi@lf@)!="number") and
               (typeof(@hi@lf@)!="resolution"))
           {
             listvar(`na@me@s[names@i]`);
           }
           kill @hi@lf@;
         }
      }
      short=@short@; //return();
   }
}
example
{  "EXAMPLE:"; echo = 2;
    ring r;
    show(r);
    ideal i=x^3+y^5-6*z^3,xy,x3-y2;
    show(i,3);            // introduce 3 space tabs before information
    vector v=x*gen(1)+y*gen(3);
    module m=v,2*v+gen(4);
    list L = i,v,m;
    show(L);
    ring S=(0,T),(a,b,c,d),ws(1,2,3,4);
    minpoly = T^2+1;
    ideal i=a2+b,c2+T^2*d2; i=std(i);
    qring Q=i;
    show(Q);
    map F=r,a2,b^2,3*c3;
    show(F);
// Apply 'show' to i (which does not belong to the basering) by typing
// ring r; ideal i=xy,x3-y2; ring Q; show(r,"i");
}
///////////////////////////////////////////////////////////////////////////////

proc showrecursive (def @@id,poly p,list #)
"USAGE:   showrecursive(id,p[,ord]); id any object of basering, p= product of
         variables and ord=string (any allowed ordstr)
DISPLAY: display 'id' in a recursive format as a polynomial in the variables
         occuring in p with coefficients in the remaining variables. This is
         done by mapping to a ring with parameters [and ordering 'ord',
         if a 3rd argument is present (default: ord=\"dp\")] and applying
         procedure 'show'
RETURN:  no return value
EXAMPLE: example showrecursive; shows an example
"
{
   def P = basering;
   int ii;
   string newchar = charstr(P);
   string neword = "dp";
   if( size(#) == 1 ) { neword = #[1]; }
   string newvar;
   for( ii=1; ii <= nvars(P); ii++ )
   {
      if( p/var(ii) == 0 )
      {
         newchar = newchar + ","+varstr(ii);
      }
      else
      {
         newvar = newvar + ","+varstr(ii);
      }
   }
   newvar = newvar[2,size(newvar)-1];

   execute("ring newP=("+newchar+"),("+newvar+"),("+neword+");");
   def @@id = imap(P,@@id);
   show(@@id);
   return();
}
example
{ "EXAMPLE:"; echo=2;
   ring r=2,(a,b,c,d,x,y),ds;
   poly f=y+ax2+bx3+cx2y2+dxy3;
   showrecursive(f,x);
   showrecursive(f,xy,"lp");
}
///////////////////////////////////////////////////////////////////////////////

proc split (string s, list #)
"USAGE:    split(s[,n]); s string, n integer
RETURN:   same string, split into lines of length n separated by \
          (default: n=pagewidth)
NOTE:     may be used in connection with lprint
EXAMPLE:  example split; shows an example
"
{
   string line,re; int p,l;
   if( size(#)==0 ) { int n=pagewidth; }
   else { int n=#[1]; }
   if( s[size(s),1] != newline ) { s=s+newline; }
   l=size(s);
   while( 1 )
   {
      p=1;
      l=find(s,newline); line=s[1,l];
      while( l>=n )
      {
         re=re+line[p,n-2]+"\\"+newline;
         p=p+n-2; l=l-n+2;
      }
      re=re+line[p,l-1]+"\\"+newline;
      l=size(line);
      if( l>=size(s) ) break;
      s=s[l+1,size(s)-l];
   }
   return (re[1,size(re)-2]);
}
example
{  "EXAMPLE:"; echo = 2;
   ring r= 0,(x,y,z),ds;
   poly f = (x+y+z)^4;
   split(string(f),50);
   split(lprint(f));
}
///////////////////////////////////////////////////////////////////////////////

proc tab (int n)
"USAGE:   tab(n);  n integer
RETURN:  string of n space tabs
EXAMPLE: example tab; shows an example
"
{
   if( n==0 ) { return(""); }
   string s=" ";
   return(s[1,n]);
}
example
{  "EXAMPLE:"; echo = 2;
   for(int n=0; n<=5; n=n+1)
   { tab(5-n)+"*"+tab(n)+"+"+tab(n)+"*"; }
}
///////////////////////////////////////////////////////////////////////////////

proc pause(list #)
"USAGE:    pause([ prompt ])  prompt string
RETURN:   none
PURPOSE:  interrupt the execution of commands, displays prompt or pause
          and waits for user input
NOTE:     pause is useful in procedures in connection with printlevel to
          interrupt the computation and to display intermediate results.
SEE ALSO: read, printlevel
EXAMPLE : example pause; shows an example
"
{
  string pr="pause>";
  if (size(#)!=0)
  {
    pr=#[1];
  }
  pr=read("",pr);
}
example
{ "EXAMPLE:"; echo=2;
  // can only be shown interactively, try the following commands:
  // pause("press <return> to continue");
  // pause();
  // In the following pocedure TTT, xxx is printed and the execution of
  // TTT is stopped until the return-key is pressed, if printlevel>0.
  // xxx may be any result of a previous computation or a comment, etc:
  //
  // proc TTT
  // { int pp = printlevel-voice+2;  //pp=0 if printlevel=0 and if TTT is
  //    ....                         //not called from another procedure
  //    if( pp>0 )
  //    {
  //       print( xxx );
  //       pause("press <return> to continue");
  //    }
  //     ....
  // }
}
///////////////////////////////////////////////////////////////////////////////