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 1996

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

Search the Archive

Re: patterns

  • To: mathgroup at
  • Subject: [mg3734] Re: patterns
  • From: ianc (Ian Collier)
  • Date: Sun, 14 Apr 1996 02:59:46 -0400
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

In article <4ki9uv$9dm at>, Susan Rempe
<rempe at> wrote:

> I have a list of numbers and symbols.
> How can I collect all the members of the list
> which have a common denominator?
> ex.  list={Sin[theta]/r, Cos[theta]/(r*s), 2*Csc[theta]/(2*r)}
>  Say I want to collect all members of the list with r in the denominator;
>  i.e.  answer=Sin[theta]/r;

If you know exactly what the denominator you want to select is then the
folling will work:

    list={Sin[theta]/r, Cos[theta]/(r*s), 2*Csc[theta]/(2*r)}
     Sin[theta]  Cos[theta]  Csc[theta]
    {----------, ----------, ----------}
         r          r s          r


    Select[list, crit] picks out all elements ei of list for
       which crit[ei] is True. Select[list, crit, n] picks out
       the first n elements for which crit[ei] is True.

    Select[ list, Denominator[ # ]==r&]
     Sin[theta]  Csc[theta]
    {----------, ----------}
         r           r

You can use more sophisticated selction criteria if you wish.

I hope this helps.


Ian Collier
Wolfram Research, Inc.
tel:(217) 398-0700   fax:(217) 398-0747    ianc at
Wolfram Research Home Page:


  • Prev by Date: Re: patterns
  • Next by Date: Help Wanted
  • Previous by thread: Re: patterns
  • Next by thread: Re: patterns