anon_swe
anon_swe

Reputation: 9335

Scheme: Can't seem to load file

Trying to load a scheme file from terminal. I've created one called test.scm containing the following code:

(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))
    )
)

and I run:

1) scheme (everything starts up fine on OS X) 2) load 'test.scm'

I get back:

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

1 ]=>
;Value: test.scm

3) (sum-of-squares 3 4)

I'm expecting 25 but instead I get:

;Unbound variable: sum-of-squares

Any idea what's going on here? When I try:

(square 5)

I get back 25 as expected...

Upvotes: 3

Views: 1933

Answers (1)

Sylwester
Sylwester

Reputation: 48745

You have evaluated the symbol load. You got back #[compiled-procedure 13 ("load" #x2) #x1a #x1045a82c2] which says load is a procedure.

You'll get something similar if you evaluate any of the other standard procedures, like +, however if you want to use + you use parentheses and arguments like (+ 2 3) ; ==> 5.

If you want to use the procedure loadyou need to use parentheses:

(load "test.scm")

Upvotes: 10

Related Questions