Bill Allombert on Thu, 14 Feb 2013 22:41:51 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
PARI 2.6 syntax 1: iferr/iferrname |
Dear developers, We are working toward finalising PARI 2.6 and release PARI 2.7. So the first thing we need to do is to stabilize the GP interface, in particular the iferr/iferrname interface. Do you use it ? Do you have example of code that use it ? This is an example of the iferr interface: invmod(a,N)= { iferr(Mod(b,N)^-1 ,E, my(T); if(errname(E)=="e_INV"&&type(T=component(E,2))=="t_INTMOD", return([gcd(lift(T),N)]) ,error(E))); } iferrname allows to simplify a bit: invmod(a,N)= { iferrname("e_INV" ,Mod(b,N)^-1 ,E ,my(T); if(type(T=component(E,2))=="t_INTMOD", return([gcd(lift(T),N)]) ,error(E))); } but the imbricated 'if' seems clumsy. Maybe we could allow: my(T); iferrname("e_INV", Mod(b,N)^-1 ,E ,type(T=component(E,2))=="t_INTMOD" ,return([gcd(lift(T),N)])) Better idea ? Another example: fun(x)= { iferrname("e_DOMAIN", exp(-tan(x)^2) ,E ,if(component(E,1)=="tan" && component(E,4)=="Pi/2 + kPi" ,0 ,error(E))) } Cheers, Bill.