Hello. I think I understand how memq, memv, member works:
> (memq 'y '(y yes n no)) '(y yes n no) > (memq 'n '(y yes n no)) '(n no) > (memq 'racket '(y yes n no)) #f > By the way, I wrote a procedure as follows: (require srfi/13) (define (yes-or-no? arg) ; expected it returns #t or #f ; depending on input such as yes or no (letrec ((y-or-n? ; if argument is either Y or YES, ; it returns #t otherwise #f (lambda (sym) (and (memq sym '(Y YES)) #t))) (symbol-upcase ; confirm any symbol into uppercase (lambda (arg) (if (symbol? arg) (string->symbol (string-upcase (symbol->string arg))) (yes-or-no? (read)))))) (let ((sym (symbol-upcase arg))) (if (memq sym '(Y YES N NO)) (y-or-n? sym) (yes-or-no? (read)))))) I expected that (cond ((I input y or yes) returns #t) ((I input n or no) returns #f) (else this procedure waits something)) However, result is sooooo strange: > (yes-or-no? (read)) 3 2 4 foo bar baz yes y no n #f Notice that even though yes, y or no is entered, the procedure ignores and it never returns #f until n is entered. Strange. Does anyone know why this doesn't work? Thanks.
____________________ Racket Users list: http://lists.racket-lang.org/users