我正在使用實現MIT方案的SCMUTILS包進行一些工作。我從Emacs運行它,並且在使用函數時遇到了麻煩,你能幫助我嗎?不允許應用一個數字(方案)
我的代碼是:
(define ((((delta eta) f) q) t)
(let ((fmas (f (+ q (* 0.001 eta))))
(efe (f q)))
(/ (- (fmas t) (efe t)) 0.001)))
(define ((G q) t)
(dot-product (q t) (q t)))
(((((delta test-path) G) test-path) 5))
當測試路徑是:
(define (test-path t)
(up (+ (* 4 t) 7)
(+ (* 3 t) 5)
(+ (* 2 t) 1)))
而且我得到這個錯誤:
Loading "mecanica"...
;Application of a number not allowed 2501.2500000000273 (())
可能是什麼問題呢?
起初我以爲這個方案不能用test-path
這樣的結構除以一個數字,所以我把點積做成一個返回數字的函數;但那不起作用。
我試過在delta-eta
打印功能表達和錯誤進來,而這樣做的部分:
(/ (- (fmas t) (efe t)) 0.001)))
如果我拿出部分商,沒有錯誤。
當然,我失去了一些東西。希望你能幫助。謝謝!
我無法在我的Scheme實現中自行運行它。 「up」,「efe」,「dot-product」和「fmas」的定義是什麼?錯誤很簡單。在某些時候,你正在做'(some-var ...)',其中'some-var'沒有解析爲一個過程,而是一個數字。 – Sylwester 2015-04-01 21:02:24
'test-path'是一個函數,但是當你調用delta時,它被賦值給'eta'和'q'參數,然後你添加並相乘它們。 – angus 2015-04-01 22:37:42
我以爲[scmutils](https://www.google.com/?q=scmutils)是一個必須在Unix計劃(而不是emacs)上運行的軟件包,作爲SICMechanichs的一部分。 – 2015-04-01 23:08:58