Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8313 > unrolled thread
| Started by | Ted Ersek <ersekt@md.metrocast.net> |
|---|---|
| First post | 2012-02-03 07:08 +0000 |
| Last post | 2012-02-03 07:08 +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:Function Doesn't Evaluate Local Variables? Ted Ersek <ersekt@md.metrocast.net> - 2012-02-03 07:08 +0000
| From | Ted Ersek <ersekt@md.metrocast.net> |
|---|---|
| Date | 2012-02-03 07:08 +0000 |
| Subject | Re:Function Doesn't Evaluate Local Variables? |
| Message-ID | <jgg15a$bl9$1@smc.vnet.net> |
Brentt wanted to make a function that returns a pure function. Below I provide foo[n,new] which is simpler than the example he used.
foo[n_,new_]:=With[{n1=n,nn=new},ReplacePart[#,n1->nn]&]
In[2]:= foo[Index, a Sin[x]]
Out[2]= ReplacePart[#1 ,Index->a Sin[x]]&
The next two examples show how you can use With to evaluate part of a held expression.
In[5]:= With[{y=2.3+1.5}, Hold[4+2^2+y-6/2]]
Out[5]=Hold[4 + 2^2 + 3.8 - 6/2]
In[6]:= y=2.1+1.1;
With[{y=y},Hold[4+2^2+y-6/2]]
Out[7]=Hold[4 + 2^2 + 3.2 - 6/2]
Ted Ersek
See my Mathematica tips & tricks at
http://www.verbeia.com/mathematica/tips/Tricks.html
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web