I have written lists of parameter values and functional forms which I read at the top of the worksheet and use subsequently when I need numerical output.
For instance,
Parameters1 := [ s = 2 ];
Functions1 := [ U = 'proc(c) (c^(1-s)-1)/(1-s); end proc' ];
eval(eval(U(c), Functions1), Parameters1);
1
- - + 1
c
This has worked well so far. But now I have a function defined in terms of a procedure, e.g.
Parameters2 := [ s = 1 ];
Functions2 := [ U = 'proc(c) local s; if s=1 then log(c); else (c^(1-s)-1)/(1-s); end if; end proc' ];
eval(eval(U(c), Functions2), Parameters2);
(1 - s)
c - 1
------------
1 - s
I expected the above to return log(c) instead.
Is there a way to fix this?
I could extend the number of variables of the U procedure, e.g. U(c,s) instead of just U(c), but since my functions can have more than one parameter (often 5 or 6) I was hoping there'd be another way than defining U(c,s1,s2,s3,s4,s5).
Is there a better way to handle multiple functional forms and parameter values than my method?