IF + user input

Discussion of Common Lisp

IF + user input

Postby samohtvii » Mon Aug 27, 2012 4:07 am

Can someone help me. I want to ask the user a question and then do something whether they say Yes or No.
I have tried a few ways but not really sure if i am close.
Thanks
samohtvii
 
Posts: 12
Joined: Thu Aug 23, 2012 11:49 pm

Re: IF + user input

Postby sylwester » Mon Aug 27, 2012 6:16 am

You mean you want to read a line of input from console like this?

Code: Select all
  (if (string= (string-upcase (read-line *standard-input* NIL "")) "YES")
    (do-yes-stuff)
    (do-other-stuff))


There is more than one way to skin a cat. You may want to look at CL cookbook => Files
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p
sylwester
 
Posts: 83
Joined: Mon Jul 11, 2011 2:53 pm

Re: IF + user input

Postby gugamilare » Mon Aug 27, 2012 8:58 pm

gugamilare
 
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil

Re: IF + user input

Postby sylwester » Tue Aug 28, 2012 2:29 pm

gugamilare wrote:There are two function which can help you:

http://www.lispworks.com/documentation/HyperSpec/Body/f_y_or_n.htm


OMG I would never guessed that was within the standard library :D
Wonder how diverse it has been implemented since it's parsing is in "implementation dependent manner"
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p
sylwester
 
Posts: 83
Joined: Mon Jul 11, 2011 2:53 pm


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 5 guests