I'm working a little with SCMUTILS package that implements MIT SCHEME. I'm running it from Emacs and I'm having trouble when using a function, can you help me?
My code is:
(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))
Where test-path is:
(define (test-path t)
(up (+ (* 4 t) 7)
(+ (* 3 t) 5)
(+ (* 2 t) 1)))
And I'm getting this error:
Loading "mecanica"...
;Application of a number not allowed 2501.2500000000273 (())
what could be the problem?
At first I thought that scheme couldn't divide a structure like test-path
by a number, so I put the dot product to make it a function that returns a number; but that didn't work.
I've tried printing expression in the delta-eta
function and the error comes in while doing this part:
(/ (- (fmas t) (efe t)) 0.001)))
And if I take out the quotient part, there is no error.
Surely I am missing something. Hope you can help. Thanks!
Assume this
(define ((((delta eta) f) q) t)
(let ((fmas (f (+ q (* 0.001 eta))))
(efe (f q)))
(/ (- (fmas t) (efe t)) 0.001)))
is equivalent to this
(define (delta eta)
(lambda (f)
(lambda (q)
(lambda (t)
(let ((fmas (f (+ q (* 0.001 eta))))
(efe (f q)))
(/ (- (fmas t) (efe t)) 0.001))))))
Then (((((delta test-path) G) test-path) 5))
is multiplying 0.001
and test-path
at (* 0.001 eta)
. And also inside of the G
, it expects q
as a procedure however, fmas
is retrieving a procedure from G
passing a number to G
. Thus this would try to apply calculated number passing t
.