Replace unevaluated symbols
- To: mathgroup at smc.vnet.net
- Subject: [mg118857] Replace unevaluated symbols
- From: Antonio De Juárez <adejuarez at gmail.com>
- Date: Fri, 13 May 2011 06:27:41 -0400 (EDT)
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.