MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Is it possible to dynamically construct arguments to With[]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105783] Re: Is it possible to dynamically construct arguments to With[]?
  • From: dh <dh at metrohm.com>
  • Date: Fri, 18 Dec 2009 06:25:05 -0500 (EST)
  • References: <hgd7ts$bn3$1@smc.vnet.net>


Hi Leo,

First, Wrap the with in Hold. In the "With" write dummy values for the 

local variables. Then replace the dummys by actual values and finally 

relese the Hold:



Hold[With[{a = a0, b = b0}, a b]] /. {a0 -> 2, b0 -> 3} // ReleaseHold



Daniel



Leo Alekseyev wrote:

> I've been trying to construct a list of local variables for the With

> construct dynamically, with no avail.  I tried various combinations of

> Unevaluated, Hold, and even ToBoxes/MakeExpression.  I've read that

> With[] evaluates its initialization lists in a non-standard way (cf

> http://library.wolfram.com/conferences/devconf99/villegas/UnevaluatedExpressions/Links/index_lnk_7.html)

> -- is this the problem?..  Is it possible to achieve something like

> the code below?

> 

> (* this doesn't wok *)

> Clear[aa, a];

> aa = List[Unevaluated[a = 3]];

> With[aa, a*100] // Print; (* want 300 *)

> 




  • Prev by Date: User defined color function for discrete data set?
  • Next by Date: Re: Is it possible to dynamically construct arguments to With[]?
  • Previous by thread: Re: User defined color function for discrete data set?
  • Next by thread: Re: Is it possible to dynamically construct arguments to