Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6896347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:01:40+00:00 2026-05-27T07:01:40+00:00

i want to read 2 values from user input using lisp. I want to

  • 0

i want to read 2 values from user input using lisp. I want to store those in variables so i can use them in my program.

So far i have the current code:

(defun le-posicao()
  (let ((n_anel) 
        (pos_anel))
    (princ "?")
    (setf n_anel (read))
    (setf pos_anel (read))
    (when (and (integerp (n_anel)) (integerp (pos_anel)))
          n_anel pos_anel)))

I’m creating the local variables with a let function and then i want to store the values i read from input in them.

My problem is, how can i read two values from input and store the first in one variable and the second in the other? The values are supposed to come in the following format:

? value1 value2

Can someone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:01:41+00:00Added an answer on May 27, 2026 at 7:01 am

    You’re trying to use Lisp imperatively. While this is possible, it may be slightly painful.

    To make your code more functional, instead of creating variables and then mutating them, you should create names and bind values to them.

    To clarify, let is a special form, not a function; they are used to create lexically scoped bindings of names to values.

    I believe what you really want to do is:

    (let ((n_anel (read))
          (pos_anel (read)))
      (... code using but not modifying n_anel and pos_anel ...))
    

    This code avoids setf.


    Notes:

    Not sure about the parentheses in Common-Lisp’s let — I’ve been using Clojure recently!

    Also not sure whether you’re using read correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my grails application I want to read some values from properties file and
I want to read and write from serial using events/interrupts. Currently, I have it
I want to read UTF-8 input in Perl, no matter if it comes from
I'm trying to read input from the terminal. For this, I'm using a BufferedReader.
I read input from the keyboard using scanf() in a while loop and print
I want to accept 5 values from the user. However, in my code (below)
I want to read line n1->n2 from file foo.c into the current buffer. I
I am using javascript to validate user input on my aspx page. I am
i want to change a link's href based on the user's input, so far
I am building a web application where I have to read some values from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.