1 Replies - 366 Views - Last Post: 17 June 2017 - 05:46 AM Rate Topic: -----

#1 Jerence  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-June 17

Question about Scheme Language

Posted 17 June 2017 - 02:15 AM

(define(sum-of-square x y)(+(* x x)(* y y)))
(define(A x y z)(cond((>= x y z)(sum-of-square x y))((>= x z y)(sum-of-square x z))
((>= y x z)(sum-of-square y x))((>= y z x)(sum-of-square y z))
((>= z x y)(sum-of-square z x))((>= z y x)(sum-of-square z y))))



(A 1 2 3)

SchemeError: Expected 2 arguments, got 3

Current Eval Stack:
-------------------------
0: (>= x y z)
1: (A 1 2 3)


Hello everyone! I am a computer science beginner now reading SICP. There is an exercise in the book: define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. I typed the codes above and the interpreter said it was wrong. So can anyone please point out where the error is? Thank you so much!

Is This A Good Question/Topic? 0
  • +

Replies To: Question about Scheme Language

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2511
  • View blog
  • Posts: 3,983
  • Joined: 21-June 11

Re: Question about Scheme Language

Posted 17 June 2017 - 05:46 AM

The error message seems to be suggesting that >= can only be used with two arguments, but both the R5RS and the R6RS standard say that >= is variadic. I've also tested your code in three different Scheme implementations (Racket, Guile and TryScheme) and it worked fine in all three.

So which Scheme implementation are you using? Maybe it's broken or incomplete.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1