Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12142 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2012-10-22 06:11 +0000 |
| Last post | 2012-10-22 06:11 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to convert the expression 3*x to a function in Mathematica? Bob Hanlon <hanlonr357@gmail.com> - 2012-10-22 06:11 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2012-10-22 06:11 +0000 |
| Subject | Re: How to convert the expression 3*x to a function in Mathematica? |
| Message-ID | <k62o29$chm$1@smc.vnet.net> |
Note that Function has the attribute HoldAll
Attributes[Function]
{HoldAll, Protected}
convert[f_] := Function[
Evaluate[Cases[f,
_Symbol?(! NumericQ[#] &), Infinity]],
Evaluate[f]]
f = 3*x;
g = convert[f]
Function[{x}, 3 x]
g[z]
3 z
f = Sin[x + y];
g = convert[f]
Function[{x, y}, Sin[x + y]]
g[r, s]
Sin[r + s]
Bob Hanlon
On Sun, Oct 21, 2012 at 2:10 AM, <pedro_fr_22@hotmail.com> wrote:
> In doing a program in Mathematica that receives an expression called f and converts it to a function. However the command Function[x,f] doesn't work, what do I do?
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web