Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*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 2004

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

Search the Archive

Re: labeling problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46446] Re: labeling problem
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Thu, 19 Feb 2004 03:01:53 -0500 (EST)
  • References: <c0utqu$e60$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

lst={{a,b},{c,d},e,f,{g,h,i},j,k,
      {l.m},{n,o,p},q,{r,s},{{t}}};

ToExpression[Table[
      "p"<>ToString[k]<> "="<>ToString[lst[[k]]],
      {k,Length[lst]}]];

p5

{g,h,i}

p9

{n,o,p}


Bob Hanlon

In article <c0utqu$e60$1 at smc.vnet.net>, Janos <janos.lobb at yale.edu> wrote:

<< I need to assign  names to list elements in a nested list based upon 
their position in the nested list.  For example if I have a list:

lst = {{a,b},{c,d},e,f,{g,h,i},j,k,{l.m},{n,o,p},q,{r,s},{{t}}}

then
pos=Position[lst,{_,_,_}] will give me

{{5}.{9}}

Now, I am thinking to assign a unique name to the list elements on 
these positions, like p5={g,h,i} and p9={n,o,p}.  I did not find yet 
how to create variable names with concatenation auto-magically from 
program.  In other programming languages I can do something like this:

var="p"+NumToString[5]
&var={a,b,c}

and I could refer to it afterward as p5 and its value would be {a,b,c}. 


  • Prev by Date: RE: Bloomberg and Mathematica
  • Next by Date: Re: labeling problem
  • Previous by thread: Re: labeling problem
  • Next by thread: Re: labeling problem