MathGroup Archive 2000

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24430] Re: [mg24385] Re: [mg24308] With[{software=Mathematica}, Frustration]
  • From: BobHanlon at aol.com
  • Date: Tue, 18 Jul 2000 00:58:28 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 7/12/2000 11:51:17 PM, siegman at stanford.edu writes:

>In article <vfca5.325$f6.112205 at ralph.vnet.net>, Wolf Hartmut 
><hwolf at debis.com> wrote:
>
>> In[2]:= With[{a = 2, b = 3}, Evaluate[c]]
>> Out[2]= 6
>> 
>> will do what you want! Why? What was meant saying by the quotations 
>> is that With gives a *textual* substitution for the given variables 
>> occuring in the *unevaluated* body.
>
>
>Thanks for this reply, and others.  But, there is still frustration.
>
>What I really want is as follows.  I'm entering a bunch of functional 
>relations like c = a b, using direct assignments (=, not :=) and being
>
>careful not to give values to the independent variables like a and b as
>
>I go along
>
>At various points I'd like to print out numerical test values or  check
>
>values of these functions, like for example
>
>   With[ {a=2, b=3}, 
>           Print["a = ",a,",  b = ",",  c =",c,",  Sin[c] = ",Sin[c] ]
>]
>
>just to check what some typical values might be, or to check that the 
>results are reasonable.
>
>Challenges:  
>
>1) Try wrapping the "Print" statement, or the "c" value, or the 
>"Sin[c]", or various combinations of these, within Evaluate[]'s -- **and
>
>then try predicting in advance, based on your knowledge of Mathematica,
>what 
>these different combinations will do**.
>
>2)  Find *any* combination of With, Print and Evaluate that will 
>accomplish the elementary "print a trial result" task that's wanted 
>above.  (I haven't found one yet.).
>
>3)  Finally, reconsider your explanation of *textual* substitution.  
>With[ ] will "textually substitute" within the Evaluated form of c -- 
>but not in the "a =" strings -- which are expressions -- and hence 
>should be "variables" in a sense..  Try, for example
>
>   With[{a=2}, Evaluate[{"a = ",a}]
>
>What gets "textually substituted"? -- what's Mathematica "code"? (see 
>the Book) -- in this case, and what isn't?
>


With[{a = 2, b = 3}, 
  Evaluate[StringForm["a = ``, b = ``, c = ``, sin(c) = ``", a, b, c, 
      Sin[c]]]]


Bob Hanlon


  • Prev by Date: RE: fade to mauve
  • Next by Date: ReadList: Is it really slow?
  • Previous by thread: Re: With[{software=Mathematica}, Frustration]
  • Next by thread: Re: With[{software=Mathematica}, Frustration]