Ian,

`oh` is indeed unbound inside the call to `call/cc`.

`oh` is only bound within the body of the `lambda` that is on the
right-hand side of the `letrec`; it is not bound in the body of the
`letrec`, which is where the call to `call/cc` is.

I don't have my copy of TSS handy. Did you make a mistake while
transcribing the program?

Vincent




On Tue, 08 Nov 2016 12:48:14 -0600,
Ian Thomas wrote:
> 
> Hello list,
> 
> I've been working through The Seasoned Schemer and have come across code that 
> I can't access in the Racket REPL: specifically, the version of rember1* 
> shown on p. 139 of the 17th chapter.
> 
> I'm not sure why there is a complaint about the 'oh' variable being unbound 
> in the last let form. 
> 
> Any suggestions/explanations would be most welcome. 
> 
> 
> Geiser error message.
> racket@> ,enter 
> "/Users/ian/src/Scheme/books/the_seasoned_schemer/017_we_change_therefore_we_are.rkt"
> 017_we_change_therefore_we_are.rkt:226:28: oh: unbound identifier in module
>   in: oh
>   context...:
>    /Applications/Racket v6.6/collects/racket/private/more-scheme.rkt:261:28
>    standard-module-name-resolver
>    /Users/ian/.emacs.d/geiser/scheme/racket/geiser/user.rkt:54:0: enter!
>    /Applications/Racket v6.6/collects/racket/private/misc.rkt:88:7
> 
> Dr. Racket message.
> oh: unbound identifier in module in: oh
> 
> 
> Below is the code.
> ;;rember1*                                                                    
>                  
> (define rember1*
>   (lambda (l a)
>     (letrec ([R (lambda (l oh)
>               (cond
>                [(null? l)
>                 (oh (quote no))]
>                [(atom? (car l))
>                 (if (eq? (car l)
>                          a)
>                     (cdr l)
>                     (cons (car l)
>                           (R (cdr l)
>                              oh)))]
>                [else
>                 (let ([new-car (call/cc oh
>                                         (R (car l)
>                                            oh))])
>                   (if (atom? new-car)
>                       (cons (car l)
>                             (R (cdr l)
>                                oh))
>                       (cons new-car
>                             (cdr l))))]))])
>       (let ([new-l (call/cc oh
>                             (R l
>                                oh))])
>         (if (atom? new-l)
>             l
>             new-l)))))
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to