Code: Select all
(dotimes (i 10 nil)
(setf xi 'value for xi))
Code: Select all
>x1
--> value for x1
>x2
--> value for x2
...
Code: Select all
(dotimes (i 10 nil)
(setf xi 'value for xi))
Code: Select all
>x1
--> value for x1
>x2
--> value for x2
...
Code: Select all
(let ((x1 44)) ...)
Code: Select all
(let ((x (list 0 1 2 3 4 5 6 7 8)))
(format t "~%X@4: ~d" (elt x 4))
(setf (elt x 6) 'a-new-value)
(format t "~%X is now: ~a" x))
It sounds like you want an array. A list will work, but IMO it's never too early to start thinking about choosing the right data structure. Trying to fake arrays with variables is a common newbie mistake. Note that I'm assuming you'll actually be accessing elements by index (e.g. a list with nth, or an array with aref). For other algorithms, a list might be the right choice.black_hat wrote:Thanks Warren and sorry for not recognizing your other post. After rethinking "how" I was going to use the data in the variables at a later point I decided to simply go with a list containing the data of the n variables. Later when I add to the list (the list will grow), since the operations will be in succession, I will just append to the end of the list thus I can access with the nth function.