This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Saving a list of variables

4 posts · 3229 views

How can you get input from a user and save that data in a list. e.g.
(format t "First question?")
(let ((firstQuestion (read-line)))
//second question
(let ((secondQuestion (read-line)))
//third
(let ((thirdQuestion (read-line)))
(setq allQuestions '(firstQuestion secondQuestion thirdQuestion))))

so that just gives me a list of those words and not the actually valuse they hold.

Thanks

Re: Saving a list of variables

(setq allQuestions (list firstQuestion secondQuestion thirdQuestion))

Re: Saving a list of variables

A hint for posting. For code, please put your code between [­­­code] and [­­­/code] tags. For example type this into a post:
[code]
(lisp (lisp (lisp that is)
            indented
            nicely))
[/code]
Just press the [­­­code] button when you're typing your post to insert the code tags. For more information, see http://lispforum.com/faq.php?mode=bbcode. Don't forget, semi-colon (;) is for Lisp comments, not //. Thanks for listening :).
blog.metalight.net

Re: Saving a list of variables

Or you can do this:
(defvar *Q* '("Foo?" "Bar?" "Baz?"))
(loop for question in *Q*
      do (format t "~a " question) (finish-output)
      collect (read-line))
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.