:= , Set , Clear , Local , ++ , -- , Object , LazyGlobal , Variables

Variables


x:=y

x:=y : Assignment. The ":=" operator can be used for three different types of assignment: Assigning a variable: as in "x:=2;", Defining a new function: as in "f(x):=Sin(2*x);", or Assigning a list item a value: as in "list[i] := 2;"


Set(variable, value)

Set(variable, value) : Sets variable to evaluated value and returns "True".


Clear(...)

Clear(...) : Makes sure variables specified in "..." are not bound any more to a value, and returns True.


Local(...)

Local(...) : Mark the variables in the unevaluated argument list as local variables (local within a Prog block or a function).


x++

x++ : increment the variable "x".


x--

x-- : decrement the variable "x".


Object("predicate",object)

Object("predicate",object) : declaration of an incomplete object. This function returns "object" as soon as "predicate" returns "True" on it. Example: "Object("IsNumber",x);" returns itself, where if x was an integer, it would return that integer.


LazyGlobal

Internal function
Calling Sequence:
LazyGlobal(var)
Parameters:
var - variable (held argument)
Description:
LazyGlobal enforces that a global variable will re-evaluate when used. The global variable needs to exist for this function to work. Also, this functionality doesn't survive if Clear(var) is called afterwards.

Places where this is used include the global variables % and I.

The use of lazy in the name stems from the concept of lazy evaluation. The object the global variable is bound to will only be evaluated when called. The LazyGlobal property only holds once: after that, the result of evaluation is stored in the global variable, and it won't be reevaluated again:
In> a:=Hold(Taylor(x,0,30)Sin(x))
Out> Taylor(x,0,30)Sin(x);
In> LazyGlobal(a)
Then the first time you call a it evaluates Taylor(...) and assigns the result to a. The next time you call a it immediately returns the result. LazyGlobal is called for "%" each time "%" changes.
Examples:
In> a:=Hold(2+3)
Out> 2+3;
In> a
Out> 2+3;
In> LazyGlobal(a)
Out> True;
In> a
Out> 5;

See Also:
Set , Clear , Local ,