“申请:不是程序"在行列式代码中 [英] "application: not a procedure" in determinant code
问题描述
应用程序:不是程序;期望一个可以应用于参数的过程给定:2参数...:-4-612-3127
application: not a procedure; expected a procedure that can be applied to arguments given: 2 arguments...: -4 -6 12 -3 1 2 7
鉴于以下代码,此错误意味着什么?
(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)
*这是我第一天使用scheme
*This is my first day working with scheme
推荐答案
你有很多语法错误 - 缺少括号、错误的括号等.你应该在编写下一个程序之前彻底测试每个程序,不要等到你有大量代码开始测试.试试这个:
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)
你想用 prod-inv
和 prod-inv-2
做什么?我修复了编译错误,但要确保它们实现了作业中给出的算法.prod-inv-2
似乎不正确.
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.
这篇关于“申请:不是程序"在行列式代码中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!