MathGroup Archive 2002

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

Search the Archive

Re: Extracting a sub-list?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37950] Re: [mg37933] Extracting a sub-list?
  • From: "Florian Jaccard" <jaccardf at eicn.ch>
  • Date: Thu, 21 Nov 2002 00:38:22 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com


Here a easy way :

In[7]:=DeleteCases[Table[x/2, {x, 1, 5}], x_ /;  !IntegerQ[x]]

Out[7]={1, 2}

Meilleures salutations

Florian Jaccard


-----Message d'origine-----
De : AngleWyrm [mailto:no_spam_anglewyrm at hotmail.com]
Envoyé : mer., 20. novembre 2002 15:09
À : mathgroup at smc.vnet.net
Objet : [mg37933] Extracting a sub-list?


How do I extract the subset of answers in a list that are pure integers?
As an example,

in:
Table[x/2, {x, 1, 5}]
IntegerQ /@ %

out:
{ 1/2, 1, 3/2, 2, 5/2 }
{ False, True, False, True, False }

But I want to get a result of:
{ 1, 2 }

-:¦:-
AngleWyrm





  • Prev by Date: RE: Extracting a sub-list?
  • Next by Date: Re: simplify expr to = 1
  • Previous by thread: RE: Extracting a sub-list?
  • Next by thread: Re: Extracting a sub-list?