Maxima 5.47.0 Manual: Introduction to Strings

Next: Functions and Variables for Strings, Previous: Strings, Up: Strings [Contents][Index]

#### 5.2.1 Introduction to Strings

Strings (quoted character sequences) are enclosed in double quote marks `"` for input, and displayed with or without the quote marks, depending on the global variable `stringdisp`.

Strings may contain any characters, including embedded tab, newline, and carriage return characters. The sequence `\"` is recognized as a literal double quote, and `\\` as a literal backslash. When backslash appears at the end of a line, the backslash and the line termination (either newline or carriage return and newline) are ignored, so that the string continues with the next line. No other special combinations of backslash with another character are recognized; when backslash appears before any character other than `"`, `\`, or a line termination, the backslash is ignored. There is no way to represent a special character (such as tab, newline, or carriage return) except by embedding the literal character in the string.

There is no character type in Maxima; a single character is represented as a one-character string.

The `stringproc` add-on package contains many functions for working with strings.

Examples:

    (%i1) s_1 : "This is a string.";
    (%o1)                   This is a string.

    (%i2) s_2 : "Embedded \"double quotes\" and backslash \\ characters.";
    (%o2) Embedded "double quotes" and backslash \ characters.

    (%i3) s_3 : "Embedded line termination
    in this string.";
    (%o3) Embedded line termination
    in this string.

    (%i4) s_4 : "Ignore the \
    line termination \
    characters in \
    this string.";
    (%o4) Ignore the line termination characters in this string.

    (%i5) stringdisp : false;
    (%o5)                         false

    (%i6) s_1;
    (%o6)                   This is a string.

    (%i7) stringdisp : true;
    (%o7)                         true

    (%i8) s_1;
    (%o8)                  "This is a string."

Categories:Syntax ·

Next: Functions and Variables for Strings, Previous: Strings, Up: Strings [Contents][Index]