MathGroup Archive 2003

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

Search the Archive

Re: Symbols and Lists

  • To: mathgroup at
  • Subject: [mg39858] Re: Symbols and Lists
  • From: atelesforos at (Orestis Vantzos)
  • Date: Sun, 9 Mar 2003 05:26:38 -0500 (EST)
  • References: <b4c8e4$n7k$>
  • Sender: owner-wri-mathgroup at

To assign the j-th element of dd to the i-th element of ss, use
Evaluate[ ss[[i]]] ] = dd[[j]]

The problem is that once you do this, ss will still change, since the
new definition for eg. c will be used.

If you want to associate symbols with values without affecting the
symbols (to  create a hashtable in other words) do this:
For instance ssHash[c] ^= dd[[4]].
Now you can retrieve the 'value' of c with ssHash[c] and still get
back ss.

Another way to do this is with rules:
ssRules={a->dd[[1]], b->d[[3]], c->d[[4]], ...}
c/.ssRules will return the 'value' of c
and First/@ssRules will give back ss.

Hope that helped,

Goyder Dr HGD <H.Goyder at> wrote in message news:<b4c8e4$n7k$1 at>...
> Dear MathGroup,
> I am doing something much more complicated but this trivial example
> expresses my difficulty.
> If I have a list of symbols and a list of data such as 
> ss = {a, b, c, d, e}
> dd = {1, 5, {3, 4}, 7, abc, {0.1, 0.001}, 3.1415}
> how do I take a symbol from the list ss and associated it with data from the
> list dd?
> A wrong attempt is to try
> ss[[3]] = dd[[4]]
> This replaces element 3 in ss with element 4 from dd.
> What I need is an assignment so that, in this case, the symbol c is
> associated with the data. Equivalent to writing 
> c = dd[[4]]
> so that c could then be used in subsequent expressions and the list ss is
> unchanged.
> Note that this is a trivial example for pedagogic purposes - I can't do the
> simple assignment in my actual case.
> Thanks
> Hugh Goyder

  • Prev by Date: Re: Help with FindRoot
  • Next by Date: Re: nth differences
  • Previous by thread: RE: Symbols and Lists
  • Next by thread: Re: Symbols and Lists