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

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

	
Recursion isn't the problem. Your use of it is, however. Replace it with "arg" and see what happens. 


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

> Yes. Actually I try making an old-fashoned game, like Lemonade Stand on Apple ][, and this is a part of the code. It controls input of the game.
> 
> Is this a problem around recursive? Isn't it good idea to use 'read' with a recursive structure?  
> 
> 
> 2013/12/31 Matthias Felleisen <matthias at ccs.neu.edu>
> 
> 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.