Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2343
| From | Antonio De Juárez <adejuarez@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Replace unevaluated symbols |
| Date | 2011-05-13 10:29 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iqj160$rh8$1@smc.vnet.net> (permalink) |
Given an expression like
{x+y,2*x-y}
I would like to replace x and y with some values even if these
variables have some value assigned. For example, the code
expr = Hold[x+y,2x-y]
expr/.x->3
produces
Hold[3 + y, 2*3 - y]
but the code
x=2.5;
expr = Hold[x+y,2x-y]
expr/.x->3
produces the wrong result
Hold[x + y, 2 x - y]
I know this can be done using Block; however, I don't know the
variables to be replaced beforehand. I would like to have a function
with attribute HoldAll like
fun[expr,var1,value1,var2,value2,...]
that replaces the variables var1, var2, ... by the corresponding
values value1, value2,..., even if any of the variables var1, var2,...
has a preassigned value.
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Replace unevaluated symbols Antonio De Juárez <adejuarez@gmail.com> - 2011-05-13 10:29 +0000
Re: Replace unevaluated symbols David Reiss <dbreiss@gmail.com> - 2011-05-14 07:10 +0000
Re: Replace unevaluated symbols Albert Retey <awnl@gmx-topmail.de> - 2011-05-14 07:15 +0000
Re: Replace unevaluated symbols Antonio De Juárez <adejuarez@gmail.com> - 2011-05-15 11:05 +0000
csiph-web