Previous Up Next

2.4.1  Character and string : "

" is used to delimit a string. A character is a string of length one.
Do not confuse " with (or quote) which is used to avoid evaluation of an expression . For example, "a" returns a string of one character but ’a’ or quote(a) returns the variable a unevaluated.
When a string is input in a command line, it is evaluated to itself hence the output is the same string. Use + to concatenate two strings or a string and another object.
Example :
Input :

"Hello"

"Hello" is the input and also the output.
Input :

"Hello"+", how are you?"

Output :

"Hello, how are you?"

The index notation is used to get the n-th character of a string, (as for lists). Indices begin at 0 in Xcas mode, 1 in other modes.
Example :
Input :

"Hello"[1]

Output :

"e"

Previous Up Next