I don't understand why you keep using "local", which, as I said, is a
*special-purpose
mechanism* for things *other than* normal variable values.
Function arguments (whether named functions or lambdas) are of course
local, as are block variables (which are in *square brackets*, not in
local()):
x:23$
lambda([x],x:1)(17)$
f(x):= x:1$ f(1)$
block([x],x:1)$
x; => 23
-s
On Fri, Mar 22, 2013 at 6:50 PM, Thomas D. Dean <tomdean at speakeasy.org>wrote:
> 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
>