Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wrong types for '-': REAL and SYMBOL
#1
I am getting the titular error from the following code

Code:
;Function definitions not shown are here

(define (sqrt-iter guess n)
   (if (goodEnough guess n)   ;<-----This line causes the error
       guess
       (sqrt-iter (improve guess n)
                   n))
)

(sqrt-iter 1.0 n)    ;<----The first call to sqrt-iter

This is basically code from the textbook and it is giving me the error in the title.  The book starts its call the same way though so I'm not sure what I'm doing differently.  Scam apparently doesn't like that I am passing a literal to a variable?
Less keys, less problems
Reply
#2
I suspect the problem is in goodEnough. Put (inspect a) and (inspect b) where a and b are the operands to the subtraction operation in goodEnough. Also, you can call scam with the -t 3 option to get more tracing information. Let us know what you find.
Reply
#3
The problem was apparently that I had "1" in my task4.args and not "(1)" and scam interpreted it as the boolean false instead of the literal value 1.  These are the results of the inspect, where n is the argument of root12.

Code:
guess is 1.0000000000
n is #f
Less keys, less problems
Reply
#4
So all is good now?
Reply
#5
(09-01-2017, 04:24 PM)lusth Wrote: So all is good now?

Yep, all fixed
Less keys, less problems
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)