Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8705
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Why HoldForm[] shows this expression in red in notebook? |
| Date | 2012-02-23 10:46 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <ji55dl$764$1@smc.vnet.net> (permalink) |
| References | <jhqml4$f9t$1@smc.vnet.net> <jhsu1o$nmq$1@smc.vnet.net> <jhvu1f$7ua$1@smc.vnet.net> |
On 21/02/2012 11:09, Nasser M. Abbasi wrote:
> On 2/20/2012 1:51 AM, David Bailey wrote:
>> On 19/02/2012 11:32, Nasser M. Abbasi wrote:
>>> foo[x_, v_] := Module[{z = v},
>>> {x^z, Hold[x^z], HoldForm[x^z]}
>>> ];
>>>
>>> Any one knows why the notebook shows the 'z' in the last term above in
>>> the red and but not the other z's?
>>>
>>> I am using V 8.04 on windows
>>>
>>> thanks
>>> --Nasser
>>>
>>>
>
>> I think the last z is coloured red because you are returning an
>> expression involving a local variable:
>>
>
> But we return expressions involving local variables all the time?
>
> foo[] := Module[{x},
> x + 3
> ]
I think the syntax colourer just fails to recognise what is going on
here. It is not fool proof.
>
> no red color any where.
>
>
> No, that would not work for me, may be I should explain
> more: I have an internal function, where I want to
> make a plot, and want to make a plot label for the plot.
>
> The plot label will be an analytical expression of
> the equation solved.
>
> I am not supposed to use Strings to formulate the
> equations for labels. So what other options are there?
>
> The way I do things now is to make labels using this
> method:
>
> Text@Row[{"equation ",Style[TraditionalForm[HoldForm[...]]]}]
>
> And in place of ... I write the equation, using standard
> Mathemtica code, as I would write it in the main cell itself
> as code. i.e. no strings.
>
> For example, to render this equation: u''[x]=f(x), I would
> write
>
> Text@Row[{"equation ",
> Style[TraditionalForm[HoldForm[u''[x] == f[x, y]]]]}]
>
> I do not want to Evaluate u''[x] ofcourse. I want just
> to display the equation itself as is.
>
> The problem comes when I do the above inside a function, which
> already has x and y as local symbols being used, like this:
>
> foo[] := Module[{x, y},
> x = 1; y = 2;
> {Text@Row[{"equation is ",
> Style[TraditionalForm[HoldForm[u''[x] == f[x, y]]]]}]
> }
> ]
>
> Now the red comes back and the $$ show up in the label which
> ofcourse I do not want.
>
> So, I have to change the code in the function, which already
> uses these symbols to use someother symbols. not good.
I'd say the simplest answer is to use global variables inside a Block
construct instead of a Module construct.
David Bailey
http://www.dbaileyconsultancy.co.uk
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why HoldForm[] shows this expression in red in notebook? "Nasser M. Abbasi" <nma%12000.org@gtempaccount.com> - 2012-02-19 11:32 +0000
Re: Why HoldForm[] shows this expression in red in notebook? David Bailey <dave@removedbailey.co.uk> - 2012-02-20 07:51 +0000
Re: Why HoldForm[] shows this expression in red in notebook? "Nasser M. Abbasi" <nma@12000.org> - 2012-02-21 11:09 +0000
Re: Why HoldForm[] shows this expression in red in notebook? David Bailey <dave@removedbailey.co.uk> - 2012-02-23 10:46 +0000
Re: Why HoldForm[] shows this expression in red in notebook? Szabolcs Horvát <szhorvat@gmail.com> - 2012-02-20 07:57 +0000
csiph-web