MathGroup Archive 2009

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

Search the Archive

Re: Select any

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101955] Re: Select any
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 24 Jul 2009 06:12:39 -0400 (EDT)
  • References: <h4955q$q9l$1@smc.vnet.net>

Do you think of sth. like
get the even numbers:

In[1]:= Select[Range[20], EvenQ]

Out[1]= {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}

or get the numbers with three prime factors (not necessarily 
                                   different 
(http://www.research.att.com/~njas/sequences/A014612))

In[2]:= Select[Range[100], Plus @@ FactorInteger[#][[All, 2]] == 3 &]

Out[2]= {8, 12, 18, 20, 27, 28, 30, 42, 44, 45, 50, 52, 63, 66, 68, \
70, 75, 76, 78, 92, 98, 99}

Study the help-topic for "Select"!

Cheers,
Peter


Niko schrieb:
> does mathematica have something like "select any" that gets any
> element of a list that satisfies a criterion?
> 


  • Prev by Date: Re: Select any
  • Next by Date: Re: Show doesn't work inside Do loop ?
  • Previous by thread: Re: Select any
  • Next by thread: Can you do something like yield in Mathematica?