"unbound identifier in module" error in Racket
Asked Answered
F

1

7

I'm writing a function in Racket, using DrRacket:

(define (same-parity a .b)
 (let ((remain (remainder a 2)))
  (define (recur-part remain-list)
   (cond ((= remain (remainder (car remain-list) 2))
         (append remain-list (list (car remain-list)))
         (recur-part (cdr remain-list)))
        (else (recur-part (cdr remain-list)))))
  (recur-part b)))

But the compiler complains the following:b: unbound identifier in module in: b

How could it be for the (recur-part b) is in the scope of the definition of same-parity?

Thanks!

Furbish answered 24/8, 2015 at 15:54 Comment(0)
M
3

Insert a space between . and b.

The problems is that .b is a legal name in Racket, so .b is in scope not b.

Maudmaude answered 24/8, 2015 at 16:0 Comment(2)
It works:) thx. Previously I thought . as a separator rather than a part of the name.Furbish
@Caesar Very easy mistake to make. In most languages it is a separator.Maudmaude

© 2022 - 2024 — McMap. All rights reserved.