On 03/22/13 14:31, Stavros Macrakis wrote:
> For ordinary variables:
>
> block( [ eq1, eq2, ...] , ...)
>
> For arrays, function definitions, adding properties to symbols, etc.:
>
> block( [], local(arr,f,x,q ),
> arr[3] : 5,
> f(x) := x^2,
> assume(x<3),
> declare(q,integer)
> )
This loses the value of x
(%i1) x:5;block(local(x), x:10, 2*x);x;
(%o1) 5
(%o2) 20
(%o3) 10
This retains the value of x
(%i1) x:5;block([x],local(x), x:10, 2*x);x;
(%o1) 5
(%o2) 20
(%o3) 5
This retains the value of x
(%i1) x:50;f(x):=(local(x), x:10, 2*x)$ f(5);x;
(%o1) 50
(%o3) 20
(%o4) 50
But, this loses the value of x
(%i1) x:50;f():=(local(x), x:10, 2*x)$ f();x;
(%o1) 50
(%o3) 20
(%o4) 10
looks like the variable must be an argument for its value to be saved.
Tom Dean