calysto_scheme
calysto_scheme copied to clipboard
Calysto Scheme does not overwrite `try` and does not throw any error when trying to do so
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.
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?
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.
You're welcome!
You can use math.sin and math.cos after importing "math"
"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".