The proper way to reproduce the code is to enter the abbreviations for the 
TSS-specific functions and to ‘copy’ the code unaltered: 

#lang racket

(define atom? symbol?)
(define t #true)
(define-syntax-rule (letcc k e) (call/cc (lambda (k) e)))

(define rember1*
  (lambda (a l)
    (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))))
               (t
                 (let ((new-car
                         (letcc oh
                           (R (car l)
                             oh))))
                   (if (atom? new-car)
                       (cons (car l)
                         (R (cdr l) oh))
                       (cons new-car
                         (cdr l)))))))))
      (let ((new-l (letcc oh (R l oh))))
        (if (atom? new-l)
            l
            new-l)))))

The text of function definition is from the source text of the book, and it 
works as expected. 

Enjoy — Matthias




> On Nov 8, 2016, at 1:48 PM, Ian Thomas <i.tho...@me.com> 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 racket-users+unsubscr...@googlegroups.com.
> 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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to