Subject: passing functions as argument one more time
From: amli at comcast.net
Date: Fri, 06 Oct 2006 19:15:06 +0000
1. How can I make sure that the functions defined in global space do not conflict with passing of
function arguments? For example I do not want f(x) defined outside the program conflict with passing the function f. (In a scipt file I may have many functions defined)
x:5;
t:3;
ff(f,x):=block([t,g,h],g:apply('f,[t]),if x<1 then h(x):=x else h(x):=3*x,ev(g,t=x)*h(2*x));
ff(sin,2); //works
f(x):=x^2;
ff(f,x):=block([t,g,h],g:apply('f,[t]),if x<1 then h(x):=x else h(x):=3*x,ev(g,t=x)*h(2*x));
ff(sin,2); //does not work
I tried this
(x):=x^2;
ff(f,x):=block([t,g,h],g:'apply('f,[t]),if x<1 then h(x):=x else h(x):=3*x,ev(g,t=x)*h(2*x));
ff(sin,2);
but how do you get the final evaluation.
2. I also do not want the functions defined inside the program such as h have global scope. How can I restrict them to be local only. I suppose I could use the kill command. Is that the only solution?
Thank you
Ram