-1

application: not a procedure; expected a procedure that can be applied to arguments given: 2 arguments...: -4 -6 12 -3 1 2 7

What does this error mean given the following code?

(define (det2x2 a b c d)(- (* a d) (* b c)))
(define (det2x2prod a1 b1 c1 d1 a2 b2 c2 d2)  (det2x2 (+ (* a1 a2)(* b1 c2))
                                                      (+   (* a1 b2)(* b1 d2))
                                                      (+   (* c1 a2)(* d1 c2))
                                                      (+   (* c1 b2) (* d1 d2))))
(det2x2prod 2 (- 4)(- 6) 12(- 3) 1 2 7)
(define (prod-inv a1 b1 c1 d1 a2 b2 c2 d2) not (= 0 (det2x2prod (a1 b1 c1 d1 a2 b2 c2 d2))))
(define (prod-inv-2 a1 b1 c1 d1 a2 b2 c2 d2)not(= 0 (det2x2(a1 b1 c1 d1)(det2x2(a2 b2 c2 d2)))))
(prod-inv   2 (- 4) (- 6) 12 (- 3) 1 2 7)
(prod-inv-2 2 (- 4)(- 6) 12 (- 3) 1 2 7)

*This is my first day working with scheme

Will Ness
  • 70,110
  • 9
  • 98
  • 181
John Friedrich
  • 343
  • 5
  • 21

1 Answers1

2

You have lots of syntax errors - missing parenthesis, erroneous parenthesis, etc. You shold test each procedure thoroughly before writing the next, don't wait until you have lots of code to start testing. Try this:

(define (det2x2 a b c d)
  (- (* a d) (* b c)))

(define (det2x2prod a1 b1 c1 d1 a2 b2 c2 d2)
  (det2x2 (+ (* a1 a2) (* b1 c2))
          (+ (* a1 b2) (* b1 d2))
          (+ (* c1 a2) (* d1 c2))
          (+ (* c1 b2) (* d1 d2))))

(det2x2prod 2 -4 -6 12 -3 1 2 7)

(define (prod-inv a1 b1 c1 d1 a2 b2 c2 d2)
  (not (= 0 (det2x2prod a1 b1 c1 d1 a2 b2 c2 d2))))

(define (prod-inv-2 a1 b1 c1 d1 a2 b2 c2 d2)
  (not (= 0 (det2x2 a1 b1 c1 d1) (det2x2 a2 b2 c2 d2))))

(prod-inv   2 -4 -6 12 -3 1 2 7)
(prod-inv-2 2 -4 -6 12 -3 1 2 7)

What were you trying to do with prod-inv and prod-inv-2? I fixed the compilation errors, but make sure that they implement the algorithm given in the assignment. prod-inv-2 doesn't seem correct.

Óscar López
  • 232,561
  • 37
  • 312
  • 386
  • 1
    Stack Overflow is _not_ a place to get your homework done. I showed you how to solve the syntax errors, but it's up to you to correctly implement the algorithms – Óscar López Aug 27 '13 at 16:45