Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: negative pattern matching anyone?

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

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

-(3 2)


3 a

Unfortunately the definitions

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

don't work, as 

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


-3 (-4)

but notice that  

holdTimes[-a, -b]
a b


pauldj at		        paolo.bientinesi at

  • 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?