Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Not accepting function as parameter

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71731] Re: Not accepting function as parameter
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Tue, 28 Nov 2006 06:03:35 -0500 (EST)
  • References: <ekbmj4$f87$1@smc.vnet.net><ekec3a$dm$1@smc.vnet.net>

Now I learn something!
There is Head Function!

Head[Sin]
Symbol

Head[Sin&]
Function

Head[Sin']
Function

Dimitris

dimitris wrote:
> Head Function???
>
> As far as I know there is not such a head.
>
> Maybe something like the following is more appropriate:
>
> Quit
>
> First here is a list of the Built-in symbols in Mathematica that have
> the the Attribute
> NumericFunction
>
> lst = ToExpression[Select[Names["System`*"],
>     MemberQ[Attributes[#1], NumericFunction] & ]]
>
> {Abs, AiryAi, AiryAiPrime, AiryBi, AiryBiPrime, ArcCos, ArcCosh,
> ArcCot,
>   ArcCoth, ArcCsc, ArcCsch, ArcSec, ArcSech, ArcSin, ArcSinh, ArcTan,
>   ArcTanh, Arg, ArithmeticGeometricMean, BesselI, BesselJ, BesselK,
> BesselY,
>   Beta, BetaRegularized, Binomial, Ceiling, ChebyshevT, ChebyshevU,
> Clip,
>   Conjugate, Cos, Cosh, Cot, Coth, Csc, Csch, Divide, EllipticE,
> EllipticF,
>   EllipticK, EllipticPi, Erf, Erfc, Erfi, Exp, ExpIntegralE,
> ExpIntegralEi,
>   Factorial, Factorial2, Fibonacci, Floor, FractionalPart, Gamma,
>   GammaRegularized, GegenbauerC, HermiteH, Hypergeometric0F1,
>   Hypergeometric0F1Regularized, Hypergeometric1F1,
>   Hypergeometric1F1Regularized, Hypergeometric2F1,
>   Hypergeometric2F1Regularized, HypergeometricU, Im, IntegerPart,
> JacobiP,
>   JacobiZeta, LaguerreL, LerchPhi, Log, LogGamma, LogIntegral,
> MathieuC,
>   MathieuCharacteristicA, MathieuCharacteristicB,
>   MathieuCharacteristicExponent, MathieuCPrime, MathieuS,
> MathieuSPrime, Max,
>   Min, Minus, Mod, Multinomial, Plus, Pochhammer, PolyLog, Power,
> Quotient,
>   Re, Rescale, RiemannSiegelTheta, RiemannSiegelZ, Round, Sec, Sech,
> Sign,
>   Sin, Sinh, SphericalHarmonicY, Sqrt, Subtract, Tan, Tanh, Times,
> UnitStep,
>   Zeta}
>
> (Head & ) /@ lst
>
> {Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol,
>   Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol,
> Symbol}
>
> Here is an example of function which if the given symbol is an element
> of the list lst.
>
> g[f_] := f[3] /; MemberQ[lst, f]
>
> g[Sin]
> Sin[3]
>
> g[a]
> g[a]
>
> g[Re]
> 3
>
> g[{Sin}]
> g[{Sin}]
>
> So for your function I would suggest the following definition
>
> happy[f_, a_Integer, b_Integer] := Module[{width = (b - a)/1000},
> f[width] /; MemberQ[lst, f]]
>
> happy[Sin, 1, 21]
> N[%]
> happy[Tan, 10, 30]
> N[%]
>
> Sin[1/50]
> 0.01999866669333308
> Tan[1/50]
> 0.020002667093402423
>
> Best Regards
> Dimitris
>
> wooks wrote:
> > This is a piece of experimental code. The function happy does not
> > evaluate whenever I pass f as a parameter as in the example below.
> >
> > Clear[happy]
> > happy[ f_Function, a_Integer, b_Integer] := Module[{width = (b -
> > a)/1000},
> >        f[width]];
> > 
> > happy[ Sin, 1, 21]
> > 
> > I'd be grateful for help.


  • Prev by Date: Re: Limit of Infinitely Nested Expression (4.0
  • Next by Date: Re: RE: Strange use of FrontEnd`FileName
  • Previous by thread: RE: Not accepting function as parameter
  • Next by thread: Re: Not accepting function as parameter