make a function that assign value to variable and is visible later



On Wednesday 18 of July 2012 20:30:13 you wrote:
> Several comments:
> 
> create_list is useful for creating a list, e.g. create_list(i,i,1,10).  It
> can also be used for side-effects, e.g. (x:2, create_list(x:x*x,i,1,10)),
> though at that point you might as well use a loop: (x:2, for i thru 10 do
> x:x*x).
> 
> There is a very big difference between x=1 and x:1.  x=1 is simply a
> mathematical expression with no side effects.  x:1 assigns the value 1 to
> the variable x.  Maxima conflates the mathematical sense of a variable with
> the programming sense of a variable, but they are really somewhat different
> (though with overlaps).

Yes I know the difference. Thank you. I do this in this way 
variable[i+1] = x(l-i+2, p+j) 
because if I make sublist as pair e.g.
[ variable[i+1], x(l-i+2, p+j) ]
i.e.
create_list([ variable[i+1], x(l-i+2, p+j) ], i, 0, 2);
then I could not to use functions: lhs and rhs in map as i make below in 
function "fun".

Thank you all for help and your time.

I found also the following solution: 

fun(variable, j):= block(
[i, a, aL, aR],
  a: create_list( variable[i+1] = x(l-i+2, p+j) , i, 0, 2),
  [aL, aR]: [ map(lhs,a), map(rhs,a) ],
  return(map(":", aL, aR))
)$

returning the assignments. 

The solution, using the operator :: is the best. Thank you Robert Dodier.

Best wishes,
Zbigniew