[plt-scheme] error in letrec

From: Grant Rettke (grettke at acm.org)
Date: Fri Feb 20 10:36:04 EST 2009

On Wed, Feb 18, 2009 at 11:36 AM, asit <lipun4u at gmail.com> wrote:
> To my best knowledge, I tryied to fix the following code...

You tried to apply your remove procedure when it was not in scope.
Here is what makes it work:

(define one (list 10 20 30 40 50))

(define list-remove
  (lambda (ls id)
    (define len (length ls))
    (letrec ((remove
              (lambda (lis)
                (if (= (length lis) id) (car lis)
                    (remove (cdr lis))))))
      (remove ls))))

(list-remove one 2)

Posted on the users mailing list.