MathGroup Archive 2003

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

Search the Archive

Re: negative pattern matching anyone?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43933] Re: negative pattern matching anyone?
  • From: Paolo Bientinesi <pauldj at cs.utexas.edu>
  • Date: Mon, 13 Oct 2003 04:04:35 -0400 (EDT)
  • Organization: University of Texas at Austin
  • References: <blcqqj$p8h$1@smc.vnet.net> <blgio6$fvm$1@smc.vnet.net> <bllo50$bs6$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Paul Abbott wrote:
> 
> Finally, what is the application? There are possibly other better ways
> to approach such problems.
> 

Thanks again for the responses.

I have to say that I was searching for a single pattern to match
both the cases just for elegance, not for strict need.

Anyway the particular problem I'm dealing with is somewhat unnatural:
I am working with HoldForms, say:

holdTimes[x_,y_]:=HoldForm[x y]

so that 

holdTimes[3,-2]  returns

3 (-2)

but what I am particularly interested in is that the product x y is
not evaluated, while the sign of the operation can be resolved
(this to avoid situations like -(-(-(-(....  ). 
So I would like holdTimes to behave like

holdTimes[3,-2]
=
-(3 2)

and

holdTimes[-3,-a]
=
3 a


Unfortunately the definitions

holdTimes[-x_,-y_]:=holdTimes[x,y]
holdTimes[-x_,y_]:=-holdTimes[x,y]
holdTimes[x_,-y_]:=-holdTimes[x,y]
holdTimes[x_,y_]:=holdForm[x y]

don't work, as 

holdTimes[3, -4] 
= 
3 (-4)

and 

holdTimes[-3,-4]
=
-3 (-4)

but notice that  

holdTimes[-a, -b]
=
a b


--
Paolo

pauldj at cs.utexas.edu		        paolo.bientinesi at iit.cnr.it


  • Prev by Date: Re: bug in CoefficientArrays?
  • Next by Date: AW: Bizarre phenomenon
  • Previous by thread: Re: Re: negative pattern matching anyone?
  • Next by thread: Re: Re: negative pattern matching anyone?