Home Online Manual
Top
Back: string expressions
Forward: string operations
FastBack:
FastForward:
Up: string
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.21.3 string type cast

Syntax:
string ( expression [, expression_2, ... expression_n])
Type:
string
Purpose:
Converts each expression to a string, where expression can be of any type. The concatenated string of all converted expressions is returned.


The elements of intvec, intmat, ideal, module, matrix, and list, are separated by a comma. No newlines are inserted.
Not defined elements of a list are omitted.
For link, the name of the link is used.
For map, the ideal defining the mapping is converted.

Note:
When applied to a list, elements of type intvec, intmat, ideal, module, matrix, and list become indistinguishable.

Example:
 
  string("1+1=", 2);
==> 1+1=2
  string(intvec(1,2,3,4));
==> 1,2,3,4
  string(intmat(intvec(1,2,3,4), 2, 2));
==> 1,2,3,4 
  ring r;
  string(r);
==> (ZZ/32003),(x,y,z),(dp(3),C)
  string(ideal(x,y));
==> x,y
  qring R = std(ideal(x,y));
  string(R);
==> (ZZ/32003),(x,y,z),(dp(3),C)
  map phi = r, ideal(x,z);
  string(phi);
==> x,z
  list l;
  string(l);
==> 
  l[3] = 1;
  string(l); // notice that l[1],l[2] are omitted
==> 1
  l[2] = l;
  l;
==> [2]:
==>    [3]:
==>       1
==> [3]:
==>    1
  string(l); // notice that lists of list is flattened
==> 1,1
  l[1] = intvec(1,2,3);
  l;
==> [1]:
==>    1,2,3
==> [2]:
==>    [3]:
==>       1
==> [3]:
==>    1
  string(l); // notice that intvec elements are not distinguishable
==> 1,2,3,1,1
See Type conversion and casting; print; string.