(repeat 10 (setq foo (nth i somelist) foo somequantity i (+ i 1) ) )
except that the items in "somelist" are strings that represent variable names I'd like to assign to foo during loop iterations, and the second time foo appears I'd like it to evaluate to the variable name.
Is this possible?? :thinking:
Title: Re: Variable containing a variable name
Post by: Lee Mac on December 13, 2018, 04:11:29 PM
Processing lists of variables and creating multiple variables on-the-fly are usually a red flag that you should be using lists instead to manipulate your data; but if you really wish to proceed down this route, then consider the read & eval functions:
(setq foo (nth i somelist) i (+ i 1) ) (set (read foo) somequantity)
Title: Re: Variable containing a variable name
Post by: Grrr1337 on December 13, 2018, 05:40:11 PM
As a possible extension of this topic, this thread (http://www.theswamp.org/index.php?topic=54171.0) might be of interest. :)
Title: Re: Variable containing a variable name
Post by: JohnK on December 14, 2018, 12:23:43 PM
Along with information already given; the method I think you are starting to describe is along the lines of a LET statement--a fun little structure to play with, if you ask me-.