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).

Examples:

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

>(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
NIL


© Colin Allen & Maneesh Dhagat
November 1999