方案:似乎无法加载文件

Scheme: Can't seem to load file

正在尝试从终端加载方案文件。我创建了一个名为 test.scm 的代码,其中包含以下代码:

(define (square x) (* x x))

(define (sum-of-squares x y) 
  (+ (square x) (square y))
)

(define (big-square x y z)
    (cond ( (and (< x y) (< x z)) (sum-of-squares y z) )
          ( (and (< y x) (< y z)) (sum-of-squares x z) )
          (else (sum-of-squares x y))
    )
)

我运行:

1) 方案(在 OS X 上一切正常) 2) 加载 'test.scm'

我回来了:

;Value 13: #[compiled-procedure 13 ("load" #x2) #x1a #x1045a82c2]

1 ]=>
;Value: test.scm

3) (sum-of-squares 3 4)

我期待 25,但我得到:

;未绑定变量:平方和

知道这里发生了什么吗?当我尝试时:

(square 5)

我按预期返回了 25...

您已评估交易品种 load。你回来 #[compiled-procedure 13 ("load" #x2) #x1a #x1045a82c2]load 是一个程序。

如果你评估任何其他标准过程,你会得到类似的东西,比如 +,但是如果你想使用 +,你使用括号和参数,比如 (+ 2 3) ; ==> 5 .

如果你想使用程序load你需要使用括号:

(load "test.scm")