[racket] Strange Behavior around memq、memv、and member

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Dec 30 16:30:05 EST 2013

On Dec 30, 2013, at 4:03 PM, 亀田馬志 <masashi.kameda at gmail.com> wrote:

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

Do you really want to recur here? 


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






Posted on the users mailing list.