Bill Daly on Wed, 23 Jun 1999 15:53:31 -0400


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

Neat trick


There are occasions when it's handy to be able to define a function
which takes another function as a parameter. This is easy in C, but
PARI/GP complains if you try the same thing. However, I've found a quick
and dirty way of fooling GP into doing it. Here is an example:

  calc(f,x) = eval(Str(f "(x)"))

If you call this with

  calc("sin",1)

it will return sin(1).

Regards,

Bill
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
**********************************************************************