MathGroup Archive 2005

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

Search the Archive

Re: pattern matching question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61847] Re: [mg61827] pattern matching question
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Tue, 1 Nov 2005 00:39:48 -0500 (EST)
  • References: <200510311110.GAA03224@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Could you post a real example or three from your notebooks?

On 10/31/05, Robert Schoefbeck <schoefbeck at hep.itp.tuwien.ac.at> wrote:
> hello everybody,
>
> i'm having the following problem: from time to times within a long
> calculation i have to perform a time consuming operation which takes a
> structure
> {{n1,m1},{n2,m2},{n3,m3},...}
> as an argument and returns a lengthy result. however, these list
> structures occur repeatedly, in fact, there are only very few (for a
> given calculation) and they occur very often. thus, i wrote a routine
> which gets all instances of these list and produces the result as a list
> of rules to be used within the actual calculation.
>
> my problem is the following:
> say, the list
> {{n1,m1},{n1,m2},{n1,m3}}
> gives
> 1/(m1-m2) + something
> and
> {{n1,m1},{n1,m1},{n1,m3}}
> gives
> 1 + something
>
> if the list of rules is now applied within the calculation the FIRST
> rule in my example is used also on the SECOND case with m1=m2 producing
> a 1/0
>
> Sorting the list of rules would of course do the trick,
> but there is no canonical way, because the generic structure of such a
> list is quite involved: any multiples of the m-parameters might occor at
> any place.
>
> What i think i need is something like
>
> {{n1,m1},{n1,m2},{n1,m3}}/;(m1=!=m2)-> 1/(m1+m2)+something
> {{n1,m1},{n1,m1},{n1,m3}}->1+something
>
> which is not mathematica syntax i believe. To put it differently: I need
> a pattern {{_,m1_},{_,m2_},{_,m3_}} to be matched only if the parameters
> are different.
>
> is there any elegant solution to this?
>
> robert schoefbeck
>
>
>


--
http://chrischiasson.com/contact/chris_chiasson


  • Prev by Date: Error: Prime::intpp: Positive integer argument expected in Prime[16.`]
  • Next by Date: Re: Some Mathematica tips & tricks
  • Previous by thread: Re: Error: Prime::intpp: Positive integer argument expected in Prime[16.`]
  • Next by thread: Re: pattern matching question