Re: Testing the Head of List Elements
- To: mathgroup at smc.vnet.net
- Subject: [mg25264] Re: Testing the Head of List Elements
- From: Harold Skolnick <hskolnic at ix.netcom.com>
- Date: Sun, 17 Sep 2000 04:47:54 -0400 (EDT)
- References: <8psf4k$9n1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi , (*List*) In[25]:= ll = {aa, 2.333, {{1.599999, 2}, 2.333333, "3"}, {"word", {w, 0}}} Out[25]= {aa, 2.333, {{1.6, 2}, 2.33333, "3"}, {"word", {w, 0}}} (*Heads of elements*) In[26]:= Map[Head, ll, {-1} ] Out[26]= {Symbol, Real, {{Real, Integer}, Real, String}, {String, {Symbol, Integer}}} (*Selected elements with head string*) In[27]:=qq = Cases[ll, _String, {-1} ] Out[27]={"3", "word"} Hope this helps. harold Marshall Bartlett wrote: > 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 > --------------------------------------------------------------