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

;Function definitions not shown are here

(define (sqrt-iter guess n)
   (if (goodEnough guess n)   ;<-----This line causes the error
       (sqrt-iter (improve guess 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
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.
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.

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

Yep, all fixed
Less keys, less problems

Forum Jump:

Users browsing this thread: 1 Guest(s)