Determine if a parameter is a function
- To: mathgroup at smc.vnet.net
- Subject: [mg101722] Determine if a parameter is a function
- From: Peter Breitfeld <phbrf at t-online.de>
- Date: Wed, 15 Jul 2009 07:10:15 -0400 (EDT)
Suppose I have a function eg
myfunc[f_,x_]:= <some definitions>
f should be a pure function like (#^2&) or Function[{x},x^2] or a named
function either self defined, like
f[x_]:=x^2 or g[x_]=x^2
or built-in like Sin, Log, ...
How can I test if f is any of these, to be able to yield a message on
wrong input?
I found that the pure-functions have Head Function, but all the others
have Head Symbol, so asking for the head is not sufficient.
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
- Follow-Ups:
- Re: Determine if a parameter is a function
- From: Leonid Shifrin <lshifr@gmail.com>
- Re: Determine if a parameter is a function