Bill Allombert on Thu, 27 Jan 2011 22:48:50 +0100


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

GP2C support for closure


Hello PARI-dev,

I have just commited code for GP2C to handle closures.
(you need gp2c SVN r765 and pari SVN r12879).

The following features are implemented:

1) evaluation of t_CLOSURE PARI objects.
sumfun(fun,a,b)=sum(i=a,b,fun(i))

2) creation of t_CLOSURE PARI objects.
trig(hyp)=if(hyp,[sinh,cosh],[sin,cos])

3) nested functions
f()=my(g(z)=z^2+1,x=2,y=g(2));x=g(x);y=g(g(y))

4) anonymous functions
f(v)=apply(z->z^2,v)
two=f->x->f(f(x))

5) closures
f(x)=z->z+x

Please test if that works for you.

Cheers,
Bill.