MathGroup Archive 2005

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

Search the Archive

Re: pattern matching question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61871] Re: [mg61827] pattern matching question
  • From: Robert Schoefbeck <schoefbeck at hep.itp.tuwien.ac.at>
  • Date: Thu, 3 Nov 2005 04:58:42 -0500 (EST)
  • References: <200510311110.GAA03224@smc.vnet.net> <acbec1a40510311014l64016fc0qe3118fe14583bec0@mail.gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

i already found out how to do it.
thanks anyways.
robert schoefbeck

On Mon, 31 Oct 2005, Chris Chiasson wrote:

> 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: Re: Re: Question regarding Mathematica's treatment of whitespace
  • Next by Date: Re: Running the kernel as a daemon?
  • Previous by thread: Re: pattern matching question
  • Next by thread: Re: Some Mathematica tips & tricks