|
4.20 string
Variables of type string are used for output (almost every type
can be "converted" to string ) and for creating new
commands at runtime see execute. They are also return values of
certain interpreter related functions (see Functions). String
constants consist of a sequence of ANY characters (including newline!)
between a starting " and a closing " . There is also a
string constant newline , which is the newline character. The
+ sign "adds" strings, "" is the empty string (hence
strings form a semigroup). Strings may be used to comment the output of
a computation or to give it a nice format. Strings may also be used for
intermediate conversion of one type into another.
| string s="Hi";
string s1="a string with new line at the end"+newline;
string s2="another string with new line at the end
";
s;s1;s2;
==> Hi
==> a string with new line at the end
==>
==> another string with new line at the end
==>
ring r; ideal i=std(ideal(x,y^3));
"dimension of i =",dim(i),", multiplicity of i =",mult(i);
==> dimension of i = 1 , multiplicity of i = 3
"dimension of i = "+string(dim(i))+", multiplicity of i = "+string(mult(i));
==> dimension of i = 1, multiplicity of i = 3
"a"+"b","c";
==> ab c
| A comma between two strings makes an expression list out of them
(such a list is printed with a separating blank in between),
while a + concatenates strings.
|