Keyboard input/Obtain a Y or N response: Difference between revisions

(→‎{{header|UNIX Shell}}: Added simplified bash version)
Line 200:
 
=={{header|Common Lisp}}==
<lang lisp>
{{incorrect|Common Lisp|The standard library function '''y-or-n-p''' requires the user to press Enter, in violation of the requirements.}}
<lang lisp>(defun rosetta-y-or-n ()
(clear-input *querystandard-ioinput*)
(loop as dum = (format t "Y or N for yes or no: ")
(y-or-n-p))</lang>
as c = (read-char)
as q = (and (not (equal c #\n)) (not (equal c #\y)))
when q do (format t "~%Need Y or N~%")
unless q return (if (equal c #\y) 'yes 'no)))
</lang>
 
=={{header|D}}==
Anonymous user