String - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

String

construct a string from expressions

 Calling Sequence String( a, b, c, ... )

Parameters

 a, b, c, ... - any expressions

Description

 • The String function concatenates zero or more expressions into a single string. Unlike the cat function, String always returns a single string, never a name, unevaluated concatenation (||), or sequence.
 • Each argument that is already a string (i.e. of type string) is appended to the result unchanged.
 • Arguments that are of type Array with one dimension or Vector, and a datatype of integer[1] (i.e. bytes) are treated as character arrays, with each entry appended to the result as a single character. If a zero valued entry is encountered, the remaining entries are skipped. This is analogous to how strings are generally used in the C and C++ (and many other) programming languages.
 (The reverse transformation, converting a string into such an Array, can be easily accomplished by passing a string to the Array function, for example, Array("This is a string.").)
 • All other arguments, x, are first converted into a 1D Maple language representation in the same form that would be produced by sprintf("%a",x), and the resulting string is appended to the result.
 • If called with no arguments, String returns the empty string, "".

Examples

The returned value is always a string.

 > $\mathrm{String}\left(\right)$
 ${""}$ (1)
 > $\mathrm{String}\left(a,b\right)$
 ${"ab"}$ (2)
 > $\mathrm{String}\left("1+1=",1+1\right)$
 ${"1+1=2"}$ (3)

One-dimensional arrays of integer[1] are interpreted as strings.

 > $\mathrm{hi}≔\mathrm{Array}\left(\left[72,101,108,108,111\right],\mathrm{datatype}={\mathrm{integer}}_{1}\right)$
 ${\mathrm{hi}}{≔}\left[\begin{array}{ccccc}{72}& {101}& {108}& {108}& {111}\end{array}\right]$ (4)
 > $\mathrm{String}\left(\mathrm{hi}\right)$
 ${"Hello"}$ (5)

All other expressions are converted into strings.

 > $\mathrm{String}\left(x+{y}^{2}\right)$
 ${"y^2+x"}$ (6)
 > $\mathrm{String}\left("a",1..5\right)$
 ${"a1 .. 5"}$ (7)
 > $\mathrm{String}\left(f\left(\right),c\right)$
 ${"f\left(\right)c"}$ (8)
 > $\mathrm{String}\left(\mathrm{hi},",",\mathrm{world}!\right)$
 ${"Hello, world!"}$ (9)

A list of strings can be converted to a single string by passing its operands to String.

 > $s≔\mathrm{convert}\left("a message",\mathrm{list}\right)$
 ${s}{≔}\left[{"a"}{,}{""}{,}{"m"}{,}{"e"}{,}{"s"}{,}{"s"}{,}{"a"}{,}{"g"}{,}{"e"}\right]$ (10)
 > $s≔\left[\mathrm{op}\left(s\right),"","for you"\right]$
 ${s}{≔}\left[{"a"}{,}{""}{,}{"m"}{,}{"e"}{,}{"s"}{,}{"s"}{,}{"a"}{,}{"g"}{,}{"e"}{,}{""}{,}{"for you"}\right]$ (11)
 > $\mathrm{String}\left(\mathrm{op}\left(s\right)\right)$
 ${"a message for you"}$ (12)

Compatibility

 • The String command was introduced in Maple 2019.
 • For more information on Maple 2019 changes, see Updates in Maple 2019.