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