Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg25232] Re: [mg25200] Testing the Head of List Elements
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sun, 17 Sep 2000 04:47:11 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Here is probably the most natural way:

In[1]:=
ls = {dog, "dog", 1, Pi}

Out[1]=
{dog, "dog", 1, Pi}

In[2]:=
Cases[ls, _String] // InputForm

Out[2]//InputForm=
{"dog"}

on 00.9.15 3:21 PM, Marshall Bartlett at 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.).
> 
> Any suggestions?
> 
> --
> --------------------------------------------------------------
> Marshall Bartlett
> Department of Geology and Geophysics
> University of Utah
> mgb_news at hotmail.com
> --------------------------------------------------------------
> 
> 
> 

-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/



  • Prev by Date: Re: Testing the Head of List Elements
  • 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