Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: enumerating list items

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56017] Re: enumerating list items
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Wed, 13 Apr 2005 01:11:05 -0400 (EDT)
  • References: <d3g96u$t4i$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Søren Merser wrote:
> hi
>
> is there a way to make each item in the list 'assignable',
> i.e. i want to enumerate the items like id=1, gender=2 etc.
>
> a={"id", "gender", "status", "odag"}
>
> b=Range@Length@a
>
> a=b
>
> regards soren

Is this what you want?

In[1]:= a = {"id", "gender", "status", "odag"}
        b = Range@Length@a
        MapThread[#1 <> " = " <> ToString@#2 &, {a,b}]

Out[1]= {id, gender, status, odag}
Out[2]= {1, 2, 3, 4}
Out[3]= {id = 1, gender = 2, status = 3, odag = 4}


  • Prev by Date: Font problems!
  • Next by Date: Re: enumerating list items
  • Previous by thread: Re: enumerating list items
  • Next by thread: Re: enumerating list items