开发者

"unbound identifier" errors in scheme

I'm using drscheme from: http://www.archlinux.org/packages/extra/x86_64/drscheme/

I'm trying to work with the sample code in my textbook, but I keep开发者_如何学Go getting getting "unbound identifier" errors. Is it because the scheme interpreter is not configured correctly? or is the code just plain wrong?

Here are a few examples:

Input:

#lang scheme
(define (equalimp lis1 lis2)
        (COND
         ((NULL? lis1) (NULL? lis2))
         ((NULL? lis2) '())
         ((EQ? (CAR lis1) (CAR lis2)) (equalimp (CDR lis1) (CDR lis2)))
         (ELSE '())
))

Output:

Welcome to DrScheme, version 4.2.5 [3m]. Language: scheme; memory limit: 128 MB.

expand: unbound identifier in module in: COND

Input:

#lang scheme
(define (quadratic_roots a b c)
  (LET (
        (root_part_over_2a
         (/ (SQRT (- (* b b) (* 4 a c))) (* 2 a)))
        (minus_b_over_2a (/ (- 0 b) (* 2 a)))
       )
  (DISPLAY (+ minus_b_over_2a root_part_over_2a))
  (NEWLINE)
  (DISPLAY (- minus_b_over_2a root_part_over_2a))
  ))

Output:

expand: unbound identifier in module in: LET

Note: I tried using LET* because I read this: stackoverflow.com/ questions/946050/using-let-in-scheme but it produces the same error.

Thanks !


It looks like a case sensitivity issue for that language setting. I know Scheme is supposed to be case-insensitive, but when I tried

(define (equalimp lis1 lis2)
        (cond
         ((null lis1) (null? lis2))
         ((null? lis2) '())
         ((eq? (car lis1) (car lis2)) (equalimp (cdr lis1) (cdr lis2)))
         (else '())
))

it worked just fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜