-1
(define (min2 a b)
  (if (> a b)
      b
      a))

(define (min3 x y z)
  (min2 (min2 x y) (min2 y z)))

(define (sum x y z)
  (- (+ x y z) min3(x y z)))

(sum 1 2 3)

error tip: ;The object 1 is not applicable.

Scheme Newbie learn Scheme, So I don't understand why (min3 1 2 3) is right, but (sum 1 2 3) is wrong?

Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57
Jerry Zhang
  • 1,198
  • 1
  • 17
  • 36
  • 1
    I voted to close as a simple typographical error, but a Google search for [`"The object is not applicable" site:stackoverflow.com`](https://www.google.com/search?q=%22The+object+is+not+applicable%22+site%3Astackoverflow.com) turned up a number of possible duplicates, including [The object ___ is not applicable](http://stackoverflow.com/q/22976298/1281433) and [Scheme Error Object Is Not Applicable](http://stackoverflow.com/q/26287081/1281433), which are both *very* similar. Please be sure to search for error messages before posting a question. – Joshua Taylor Dec 31 '14 at 03:03
  • I had searched used the error msg, but I still do not how to solve this problem. I had read http://stackoverflow.com/questions/26287081/scheme-error-object-is-not-applicable and http://stackoverflow.com/questions/22165892/typeerror-the-object-is-not-applicable before ask this question. For me, I dit not read any sckeme book, I just read "Structure and Interpretation of Computer Programs" knowing this language. – Jerry Zhang Dec 31 '14 at 05:44

1 Answers1

0

You had min3 in the wrong place in the definition of sum:

(define (sum x y z)
  (- (+ x y z) (min3 x y z)))
Dan D.
  • 73,243
  • 15
  • 104
  • 123