Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg3750] Re: [mg3727] patterns
  • From: Roberto Colistete Junior <roberto at verao.cce.ufes.br>
  • Date: Sun, 14 Apr 1996 03:02:33 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Susan Rempe 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;
> 
> ********************************************
> Susan Rempe				   *
> University of Washington		   *
> Department of Chemistry		           *
> Box 351700				   *
> Seattle, WA  98195-1700		           *
> 					   *
> (206)685-2951				   *
> rempe at u.washington.edu	                   *
> ********************************************
> 
> 
> 
   A simple way is to use "Select" and "Denominator" :

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

General::spell1:
   Possible spelling error: new symbol name "list"
     is similar to existing symbol "List".

         Sin[theta]  Cos[theta]  Csc[theta]
Out[1]= {----------, ----------, ----------}
             r          r s          r

In[2]:= answer = Select [list, (Denominator[#] === r)&]

         Sin[theta]  Csc[theta]
Out[2]= {----------, ----------}
             r           r

   Of course, Mathematica simplified the last member of the list, so the 
above answer is correct.

------------------------------------------------------------------------
Roberto Colistete Junior                     Email : roberto at cce.ufes.br
MSc Physics Student               

Departamento de Fisica
Universidade Federal do Espirito Santo
Brasil
------------------------------------------------------------------------

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Windows 95 Problems
  • Next by Date: Re: patterns
  • Previous by thread: Re: patterns
  • Next by thread: Re: patterns