Josef Eschgfaeller on Sat, 17 Oct 2015 21:11:58 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Vector of args


Is there a better way to define evalf?
Want to use f, not "f".

t_word unites several strings (or letters)
to one string.
--------------------------------------------------
\\ f(v1,...) if v=[v1,...].
evalf (f,v) = {v=Vec(Str(v)); v[1]=""; v[#v]="";
v=t_word(v,,""); eval(Strprintf("(%s)(%s)",f,v))}

\\ Examples:

f (x,y) = x+y^2;
a=evalf(f,[4,9]); print(a) \\ 85

g (x) = #x
b=evalf(g,[[1,2,3,4,5]]); print(b) \\ 5

h (x,y,z) = #x+y*z
c=evalf(h,[[1,2,3],7,10]); print(c) \\ 73
--------------------------------------------------
Thanks
Josef Eschgfaeller