MathGroup Archive 2002

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

Search the Archive

Re: Question about pattern matching

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34080] Re: [mg34057] Question about pattern matching
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Thu, 2 May 2002 03:49:19 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On Wednesday, May 1, 2002, at 08:00 AM, Mike Varney wrote:

> Hello.
> I have a rather straight forward question on pattern matching.
>
> Say that I have a expression given as:
>
> (kg m^2) /(s^2)
>
> When I try a pattern matching substitution such as:
>
> (kg m^2) /(s^2) /. (kg m)/(s^2) -> n
>
> Returns:
> (kg m^2) /(s^2)
>
>
> Am I missing some sort of rule?  How can I do this sort of pattern 
> matching.
>
> Thanks for you help.
> Mike
>
>
Use FullForm to find the right form: FullForm[(kg m^2)/s^2] is Times[kg, 
Power[m, 2], Power[s, -2]] so (kg m^2) /(s^2) /. Times[kg, Power[m, 2], 
Power[s, -2]] -> n works as does (kg m^2)/s^2/.kg m^2 s^-2->n

Regards,

Ssezi



  • Prev by Date: stupid question
  • Next by Date: Re: Question about pattern matching
  • Previous by thread: Re: Question about pattern matching
  • Next by thread: Re: Question about pattern matching