Functions Documentation
View Function Edit Function
Name eval
Syntax (eval expr) -> value of evaluated expression
Argument List expression: The thing you want to evaluate. It can handle numbers, function, strings, and lists. What it does, depends on what argument it gets.
Returns If it is passed a number or lamdba function it just returns that otherwise tries to run the list as a function and returns what that function returns, or if it is a string it returns the value of the variable with that name.
Category function operator, variable, string operator
Description Returns the evaluated expression. If it is passed a number or function it just returns that if it is a list tries to run the list as a function and return what it returns, or if it is a string it returns the value of the variable with that name.
Example
(eval '(add 1 1))
This is a list case. This will return the number 2.
(block (varies)
(setq varies "I am a variable")
(eval "varies")
)
This is a string case. This will return the string "I am a variable".
(eval (add 1 1))
Even though it is similar to the list case this is a number case (the (add 1 1) is run first). This will return the number 2.
(eval add)
This is the function case. This will return the function add.
(block (theString)
(setq theString "(add 3 5)")
(eval (link theString))
)
Maybe the most intersting use of (eval ...) is in combination with (link ...), which converts a string into an expression tree. The above example will return the integer "8".
Comment Some very interesting things can be done with this. The string case is the most interesting due to the list case can be emulated with apply and the other two cases being trivial.