|
[Date Index]
[Thread Index]
[Author Index]
Re: Function argument
- To: mathgroup at smc.vnet.net
- Subject: [mg66995] Re: Function argument
- From: "ben" <benjamin.friedrich at gmail.com>
- Date: Tue, 6 Jun 2006 06:28:17 -0400 (EDT)
- References: <e60o3q$g5s$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
you almost provided the solution yourself
Bye Ben
In[6]:=
f1[x_]:=Sin[x]
f2[x_]:=x^2+43
In[9]:=
g[a_,h_]:=h[a]
In[14]:=
g[\[Pi],f1]
g[1,f2]
Out[14]=
0
Out[15]=
44
Bonny schrieb:
> I would like to define a function g that evaluates another function f at a
> given value. That is,
>
> g[a, f[x]] := f[a]
>
> For example, I might want the function f[x]=ax^2+bx+c to be evaluated at x=1
> and get the result a+b+c. That is,
>
> g[1, ax^2+bx+c] should evaluate to a+b+c.
>
> Again, I might want the function f[x]=Sin[x] to be evaluated at x=pi and get
> the result 0. That is,
>
> g[pi, Sin[x]] should evaluate to 0.
>
> Is there a way to accomplish this in Mathematica? Any help would be
> appreciated.
>
> Thanks,
> Bonny.
Prev by Date:
Re: Function argument
Next by Date:
Re: Function argument
Previous by thread:
Re: Function argument
Next by thread:
Re: Function argument
|