Le 17/01/2017 11:46, Pierre Vuillemin a écrit :
I have actually implemented a similar solution (in the previous link)
except that the data are stored in some list. This leads to anonymous
functions that behaves as in Matlab, i.e. the data of the function is
instantiated when the function is created.
In python, the value of the data 'a' is instantiated when the function
is evaluated. Therefore, if the data 'a' changes, the function changes.
Here I could make something like
deff('y=f(x)','y = a*x')
but then the function will get the value of the variable 'a' of the
current namespace, e.g.
a = 1
function outer(x)
a = 2
disp(f(1))
endfunction
f(1) // will give 1
outer(1) // will give 2
a = 3
f(1) // will give 3
outer(1) // will give 2
In this example, I would like f(1) to behave identically independently
of its position.
If i understand correctly your query, the global space is unique and
aims to allow that:
deff('y=f(x)','global a; y = a*x')
This requires the only variable "a" you want to consider been declared
"global a" before some calling point. Actually, i don't see how to refer
to a unique "a" without telling to Scilab which one it must be.
Samuel
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users