Subject: how to pass the name of a variable as argument?
From: Stavros Macrakis
Date: Thu, 1 May 2008 20:42:29 -0400
On Thu, May 1, 2008 at 8:14 PM, Oliver Kullmann
<O.Kullmann at swansea.ac.uk> wrote:
> Since global variables should be avoided, a good
> solution would be to pass the name of a variable
> to f, so that then we could use
I am not sure that global variables are any worse than this method, but....
To name a variable, use 'var. To assign to a variable through its
name, use var :: newval. To access the value of the value of a
variable, use ev(var). So your example becomes
f(x) := x :: adjoin(1,ev(x));
and is called as
f('var)
I don't know what your overall problem is, but I think I would just
use global variables with a naming convention, e.g. global_x,
global_y, or a hasharray global['x], global['y].
-s