Re: With[{software=Mathematica}, Frustration]

*To*: mathgroup at smc.vnet.net*Subject*: [mg24370] Re: With[{software=Mathematica}, Frustration]*From*: "Drago Ganic" <drago.ganic at in2.hr>*Date*: Wed, 12 Jul 2000 23:13:11 -0400 (EDT)*References*: <8k3of0$428@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi, well in my practical experience with Mathematica (a Year of hobby learning) the subject to this post you have choose is quite correct. The only suggestion I can give You is to buy a lot of books (I would like to know how many non-genious people have learned the deep basics of Mathematica only from the Mathematica book). Doing so I can give you the answer: In[6]:=Attributes[With] Out[6]= {HoldAll, Protected} In[8]:= Attributes[ReplaceAll] Out[8]={Protected} As you can see "With" does not evaluate c, therefore {a->2, b->3} acts on c, and not on a*b (like in "ReplaceAll"). If you want that "With" behaves the same as "ReplaceAll" you schould use "Evaluate" .... In[10]:= With[{a = 2, b = 3}, Evaluate[c]] Out[10]=6 or if you want that "ReplaceAll" behaves the same as "With" you schould use "Unevaluated" In[5]:= Unevaluated[c] /. {a -> 2, b -> 3} Out[5]= a b as Stephen said in The Book (you have not quooted the * ... * part ): *Except for the question of when x and body are evaluated*, With[ax = aa, body] works essentially like body /. x -> a. So, read carefully. Greeting from Croatia, Drago Ganic "AES" <siegman at stanford.edu> wrote in message news:8k3of0$428 at smc.vnet.net... > Pages 359-360 of The Mathematica Book says (admittedly, taken a little > out of context), > > "You can think of With as a generalization of the /. operator. . ." > > and > > " With[{x=x0}, body] works essentially like body /. x->x0 . . . " > > Great, looks neat, let's try it for evaluating expressions without > permanently setting the variables in them: > > In[1]:= c = a b > > Out[1]= a b > > In[2]:= c > > Out[2]= a b > > In[10]:= c /. {a -> 2, b -> 3} > > Out[10]= 6 > > In[3]:= With[{a = 2, b = 3}, c] > > Out[3]= a b > > *Not* what I was hoping for . . . >