Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong type to apply?

Tags:

scheme

I've been playing with Scheme for about 10 minutes and stumbled across this error:

scheme@(guile-user) [2]> (define (a one two) ((* one two)))
scheme@(guile-user) [2]> (a 2 3)
ERROR: In procedure 6:
ERROR: Wrong type to apply: 6

I was expecting this to return 6. How does "apply" enter into this? What does this error mean?

like image 654
mikewilliamson Avatar asked Nov 01 '25 15:11

mikewilliamson


1 Answers

Parentheses in Scheme are not just a grouping construct. They generally mean function application.

The error is related to the body of your define. Specifically,

((* one two))

means

Call the result of multiplying one by two

The JS equivalent is something like

function a (one, two) { (one * two)(); }

You most likely meant to define that function as

(define (a one two) (* one two))

which is just the multiplication, and should work fine.

like image 179
Inaimathi Avatar answered Nov 04 '25 20:11

Inaimathi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!