calysto_scheme icon indicating copy to clipboard operation
calysto_scheme copied to clipboard

Calysto Scheme does not overwrite `try` and does not throw any error when trying to do so

Open twolodzko opened this issue 3 years ago • 3 comments

The classic SCIP handbook has this example:

(define tolerance 0.00001)

(define (fixed-point f first-guess)
  (define (close-enough? v1 v2)
    (< (abs (- v1 v2)) tolerance))
  (define (try guess)
    (let ((next (f guess)))
      (if (close-enough? guess next)
          next
          (try next))))
  (try first-guess))

The always code returns first-guess when running it in Calysto Scheme, while working correctly in other dialects of Scheme. When the code is modified by renaming try to something else, it works correctly.

I would expect it to either allows me to re-define the symbol, or at least throw an error if this is not allowed.

twolodzko avatar Jan 29 '21 15:01 twolodzko

Thanks for the note! Yes, you are correct, and in fact you'd probably have a problem with any other reserved word in Python. We should probably have a list, and behind the hood use a slightly modified name.

Everything else working well in SCIP?

dsblank avatar Jan 29 '21 16:01 dsblank

Hi,

I'm finishing exercises for the first chapter and it works fine. The only thing that I was lacking were the sin and cos functions that were needed for one or two problems, but I saw that they are not yet available in Calypso Scheme.

If there's something like the problem above, I'll let you know.

By the way, thanks for implementing it, it's a really great tool for educational purpose.

twolodzko avatar Jan 29 '21 18:01 twolodzko

You're welcome!

You can use math.sin and math.cos after importing "math"

dsblank avatar Jan 29 '21 19:01 dsblank

"Fixed" in Calysto Scheme 1.4.8. Because try is a special form, the above example will now give an error. Just use a different symbol other than "try".

dsblank avatar May 15 '23 14:05 dsblank