MathGroup Archive 2004

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

Search the Archive

labeling problem

  • To: mathgroup at
  • Subject: [mg46430] labeling problem
  • From: Janos <janos.lobb at>
  • Date: Wed, 18 Feb 2004 00:36:53 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Before I re-invent the wheel let me ask:

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}}}

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


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:


and I could refer to it afterward as p5 and its value would be {a,b,c}. 
  The most handy would be if I could take just the name of the position 
and assign that to it, like:
For[i=1, i<=Length[pos], i++, NumberToName[pos[[i]]]=lst[[pos[[i]] ]] ]

and I would get:

five={g,h,i} and nine={n,o,p}.

Of course lst[[pos[[i]] ]] where' i' goes from 1 to 2 is somewhat doing 
it but it is a little bit complicated.

I looked the book and the online documentation but could not find a 
function called NumberToName which would do


and vice versa


Is there such function or procedure in someone's drawer ?
If not, then what is the right way to get a unique variable name with 
some clear deterministic nature - like above - from Mathematica ?

Thanks ahead,

"There was a mighty king in the land of the Huns whose goodness and 
wisdom had no equal."

  • Prev by Date: RE: Re: how to explain this weird effect? Integrate
  • Next by Date: Re: how to explain this weird effect? Integrate
  • Previous by thread: Re: Computing sets of equivalences
  • Next by thread: Re: labeling problem