MathGroup Archive 2000

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

Search the Archive

Re: Testing the Head of List Elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25250] Re: [mg25200] Testing the Head of List Elements
  • From: Matt.Johnson at autolivasp.com
  • Date: Sun, 17 Sep 2000 04:47:29 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Marshall -

Use Cases:

In[75]:=
list = {1, 1.2, "abc", a, {3, 2, 1}};
In[76]:=
Cases[list, _String]
Out[76]=
{"abc"}
In[77]:=
Cases[list, _Integer]
Out[77]=
{1}
In[78]:=
Cases[list, _List]
Out[78]=
{{3, 2, 1}}

-matt





"Marshall Bartlett" <mgb_news at hotmail.com> on 09/15/2000 12:21:40 AM

cc:

Subject: [mg25250]  [mg25200] Testing the Head of List Elements


I'm something of a newbie with Mathematica; please excuse my ignorance.

I am looking for a clever way to select elements from a list based on their
type (Head).  Specifically, I want to extract all the elements of type
dtring from a list of elements of different types (string, number,
character, etc.).

Any suggestions?

--
--------------------------------------------------------------
Marshall Bartlett
Department of Geology and Geophysics
University of Utah
mgb_news at hotmail.com
--------------------------------------------------------------









  • Prev by Date: Another strange bug in Mathematica 4.0's Integrate
  • Next by Date: Re: Testing the Head of List Elements
  • Previous by thread: RE: Testing the Head of List Elements
  • Next by thread: Re: Testing the Head of List Elements