evymetal

March 8th, 2009, 05:04 PM

I've been trying to play around with Scheme a little, but I can't work out where I'm going wrong.

I know this may not be the best way to write this procedure, but I'm confused about why I can't call it

(define fact

(lambda

(x1)

(if

(eqv? x1 1)

x1

(

(* x1 (apply fact (- x1 1) )

)

)

)

)

(begin

(display

(number->string

(apply fact 1)

)

)

newline

)

and I am getting the following errors (I'm using Bigloo as the interpreter)

# (apply fact 1)

# ^

# *** WARNING:bigloo:toplevel-init

Type error -- `pair' expected, `long' provided

# (apply fact 1)

# ^

# *** WARNING:bigloo:toplevel-init

Type error -- `pair' expected, `long' provided

What am I doing wrong? surely if I pass (1) then it will just evaluate to 1, and it doesn't seem to make much sense to me if you have to pass '(1).

I know this may not be the best way to write this procedure, but I'm confused about why I can't call it

(define fact

(lambda

(x1)

(if

(eqv? x1 1)

x1

(

(* x1 (apply fact (- x1 1) )

)

)

)

)

(begin

(display

(number->string

(apply fact 1)

)

)

newline

)

and I am getting the following errors (I'm using Bigloo as the interpreter)

# (apply fact 1)

# ^

# *** WARNING:bigloo:toplevel-init

Type error -- `pair' expected, `long' provided

# (apply fact 1)

# ^

# *** WARNING:bigloo:toplevel-init

Type error -- `pair' expected, `long' provided

What am I doing wrong? surely if I pass (1) then it will just evaluate to 1, and it doesn't seem to make much sense to me if you have to pass '(1).