MathGroup Archive 2000

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

Search the Archive

Re: Testing the Head of List Elements


Suppose your list is something like {"letter",1,a}. The first element is 
a string.

In[3]:=
Select[{"letter", 1, a}, Head[#] == String &]
Out[3]=
{"letter"}

This does what you want (it's really not too clever, though).

Tomas Garza
Mexico City

"Marshall Bartlett" <mgb_news at hotmail.com> 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.).




  • Prev by Date: shortcut for cell style
  • Next by Date: Re: how to compile?
  • Previous by thread: Re: Testing the Head of List Elements
  • Next by thread: Re: Testing the Head of List Elements