Reputation: 3948
I have the following program:
(define (myFunc x e)
(let loop ((n x) (m e) (acc 2))
(cond
( (eqv? (abs (- ( * (expt -1 (+ acc 1)) (/ (expt n acc) acc) ) ( * (expt -1 (+ acc 1)) (/ (expt n (- acc 1) ) (- acc 1)) ) )) m)
(begin (display "result is: ") (display acc) #f))
(else
(loop (n) (m) (+ acc 1))
))
))
You can see that it calculates values, check for an equality, and if it does not succeed it repeats the loop.
However, when i run it i get the error:
application: not a procedure;
expected a procedure that can be applied to arguments
given: 0.5
arguments...: [none]
Pointing to the loop (n) part after my 'else' statement. Why is this happening?
Thanks!
Upvotes: 0
Views: 103
Reputation: 222973
n
and m
are (I presume) numbers, not procedures. You can't call them. And yet, when you say (n)
and (m)
, that's exactly what you're trying to do. It's equivalent to the expressions n()
and m()
in JavaScript.
Remember, in Scheme, (foo bar baz)
is equivalent to the likes of foo(bar, baz)
in JS, and (foo)
is equivalent to foo()
, and ((foo))
is equivalent to foo()()
. You cannot add parentheses willy-nilly.
Upvotes: 3