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: [mg25257] Re: [mg25200] Testing the Head of List Elements
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Sun, 17 Sep 2000 04:47:41 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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