Re: Need just enough underbars
- To: mathgroup at smc.vnet.net
- Subject: [mg18346] Re: Need just enough underbars
- From: dreiss at earthlink.net (David Reiss)
- Date: Wed, 30 Jun 1999 14:13:18 -0400
- Organization: Scientific Arts
- References: <7l5sf2$ih2@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <7l5sf2$ih2 at smc.vnet.net>, Patrick Reany <reany at xroads.com> wrote:
> I'm trying to use underbars to distinguish new variables from old in a
> differential eqn of state under a change of independent variables. I
> want all upper case letters to have an underbar in the new form. Some
> already have the underbar while others do not. How do I add the
> underbars to the ones that do not have them while not adding another
> underbar to the ones that already do. Below is an example form derived
> by using FullForm[]:
>
> Equal[Plus[Times[j,P],HoldForm[D[UnderBar[T],UnderBar[P]]],
> Times[-1,T,HoldForm[D[UnderBar[V],UnderBar[U]]]]],0]
>
> where one 'P' and one 'T' need to have the underbar added.
>
> Thanks
>
> Patrick
Here is one quick way that I just hacked together as
fast as possible. First I deconstruct the expression
by removing the underbars (assuming that the only
quantities that have underbars are capital letters --
if this isn't true then you hahave to do a bit more),
then I put them back but take care to only do this with symbols
defined in the Global' context:
j*P + HoldForm[D[UnderBar[T], UnderBar[P]]] -
T*HoldForm[D[UnderBar[V], UnderBar[U]]] /.
UnderBar[x_] :> x /.
(z_)?(UpperCaseQ[ToString[#1]] && Context[#1] ===
"Global`" & ) :> UnderBar[z]
Perhaps there are much more elegant ways of doing this...
--David
--
)------------------------------------(
) Scientific Arts: (
) Creative Services and Consultation (
) for the Applied and Pure Sciences (
) (
)---------------------------------------
) http://www.scientificarts.com
)
) David Reiss
) Email: dreiss at !Spamscientificarts.com
)---------------------------------------