Bill Allombert on Mon, 08 Feb 2016 17:56:08 +0100


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

Re: call


On Mon, Feb 08, 2016 at 05:51:24PM +0100, Bill Allombert wrote:
> On Sun, Feb 07, 2016 at 10:55:02AM +0100, Josef Eschgfaeller wrote:
> > f (x,y) = x+y
> > s=call(f,[3,5])
> > \\ not a function
> > 
> > Has call been realized under a different name (version 2.7.5)?
> 
> Alas, call is only available in PARI 2.8 master branch 

If you like a solution for PARI 2.7, see
<http://pari.math.u-bordeaux.fr/archives/pari-users-1510/msg00001.html>

The proposed solution is:

\\generate the string "v[1],...,v[n]"
genargs(n)= concat(vector(n+1,i,if(i==1,"",i==2,"v[1]",Str(",v[",i-1,"]"))))
\\ evaluate "f(v[1],...,v[n])" after setting f and v 
call(f,v)= eval(Str("f(",genargs(#v),")"))

Cheers,
Bill.