### 25.5.4 Creating symbols from strings

Variable and function names are symbols, namely sequences of characters, which are different from strings. For example, you can have a variable named abc, but not "abc". The make_symbol command turns a string into a symbol; for example make_symbol("abc") is the symbol abc.

#### Examples

make_symbol("abc"):=3

then:

abc

3 |  |  |  |  |  |  |  |  |  |

The variable abc will have the value 3. Similarly for functions:

make_symbol("sin")(pi/4)

√ |
2
2

which is equal to sinπ/4.

##### Creating arrays of symbols.

The symbol_array command is used for creating multidimensional arrays of symbols.

- symbol_array takes two mandatory arguments and one optional argument:
  - str, a template string for symbol names.
  - dim=n1,n2,…,nm, a sequence of m positive integers.
  - Optionally, purge, the symbol.
- symbol_array(str,dim ⟨,purge ⟩) returns an array with m dimensions n1,n2,…,nm with indexed symbols as elements. Symbols are created from the template string str by appending indices. Template string may contain m instances of the character ’%’, kth of which serves as the placeholder for the kth dimension index. If placeholders are omitted, indices are simply appended in case m=1, while in case m>1 they are separated from str and each other by the underscore (’_’). If purge is given, then the already assigned symbols are purged, otherwise a warning is printed for each such symbol.
- The indices are in accordance with the current syntax mode (they are either 0- or 1-based).

#### Examples

symbol_array("x",5)

| ⎡ ⎣ | x0,x1,x2,x3,x4 | ⎤ ⎦

symbol_array("a",2,3)

⎡ ⎢ ⎣ |
a0,0 | a0,1 | a0,2
a1,0 | a1,1 | a1,2
| ⎤ ⎥ ⎦

maple_mode(1):; symbol_array("a%%",2,3)

[[a 11,a 12,a 13],[a 21,a 22,a 23]] |  |  |  |  |  |  |  |  |  |

maple_mode(0):; s:=symbol_array("a%b%c%",2,3,4)

| ⎡ ⎢ ⎢ ⎣ |
⎡ ⎢ ⎢ ⎣ |
a 0 b 0 c 0 | a 0 b 0 c 1 | a 0 b 0 c 2 | a 0 b 0 c 3
a 0 b 1 c 0 | a 0 b 1 c 1 | a 0 b 1 c 2 | a 0 b 1 c 3
a 0 b 2 c 0 | a 0 b 2 c 1 | a 0 b 2 c 2 | a 0 b 2 c 3
| ⎤ ⎥ ⎥ ⎦
| , |
⎡ ⎢ ⎢ ⎣ |
a 1 b 0 c 0 | a 1 b 0 c 1 | a 1 b 0 c 2 | a 1 b 0 c 3
a 1 b 1 c 0 | a 1 b 1 c 1 | a 1 b 1 c 2 | a 1 b 1 c 3
a 1 b 2 c 0 | a 1 b 2 c 1 | a 1 b 2 c 2 | a 1 b 2 c 3
| ⎤ ⎥ ⎥ ⎦
| ⎤ ⎥ ⎥ ⎦

s[1][2][3]

a 1 b 2 c 3 |  |  |  |  |  |  |  |  |  |