Previous Up Next

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.

Examples

symbol_array("x",5)
     

x0,x1,x2,x3,x4
          
symbol_array("a",2,3)
     


a0,0a0,1a0,2
a1,0a1,1a1,2


          
maple_mode(1):; symbol_array("a%%",2,3)
     
[[a11,a12,a13],[a21,a22,a23]]           
maple_mode(0):; s:=symbol_array("a%b%c%",2,3,4)
     






a0b0c0a0b0c1a0b0c2a0b0c3
a0b1c0a0b1c1a0b1c2a0b1c3
a0b2c0a0b2c1a0b2c2a0b2c3



,



a1b0c0a1b0c1a1b0c2a1b0c3
a1b1c0a1b1c1a1b1c2a1b1c3
a1b2c0a1b2c1a1b2c2a1b2c3






          
s[1][2][3]
     
a1b2c3           

Previous Up Next