next up previous
Contents Next: About this document Up: Appendix: Selected Lisp Previous: symbolp (PREDICATE)

y-or-n-p, yes-or-no-p (PREDICATES)

Format: (y-or-n-p) (y-or-n-p <string> ) (yes-or-no-p) (yes-or-no-p <string> )

Required arguments: none

Optional arguments: 1

Optional argument must evaluate to a string

The user is prompted with the string text (if provided). y-or-n-p returns t if y or Y is entered or nil if n or N is entered, but reprompts the user if given any other response. yes-or-no-p behaves similarly but requires a yes or no respsonse (upper or lower case mixed is ok).


> (y-or-n-p "Well? ")
Well?   (Y or N) ok
Well?   (Y or N) no
Well?   (Y or N) y 

> (yes-or-no-p "Answer in full:") 
Answer in full:  (Yes or No) y
Answer in full:  (Yes or No) n
Answer in full:  (Yes or No) nO

© Colin Allen & Maneesh Dhagat
March 2007