Previous Up Next

10.4.5  Using strings as commands

The expr command will let you use a string as a command. Given a string that expresses a valid command, expr will convert the string to the command and evaluate it. For example, if you enter

expr("c := 1")

then the variable c will be set to 1. Similarly, if you enter

a := "ifactor(54)"

then

expr(a)

will return

2 * 3^3

which is the same thing as entering ifactor(54) directly.

You can also use expr to convert a string to a number. If a string is simply a number enclosed by quotation marks, then expr will return the number. For example,

expr("123")

will return

123

In particular, the following strings will be converted to the appropriate number.


Previous Up Next