bobscheme icon indicating copy to clipboard operation
bobscheme copied to clipboard

tail recursion for interpreter.py

Open natethern opened this issue 2 months ago • 1 comments

Got the idea from https://www.norvig.com/lispy.html https://www.norvig.com/lispy2.html

Create long-recursion.scm in examples:

(define (odd? n)
  (if (<= n 0)
      #f
      (even? (- n 1))))
(define (even? n)
  (if (<= n 0)
      #t
      (odd? (- n 1))))
(write (even? (* 7 7 7 7 7 7 7)))

python compile_file.py long-recursion.scm && python run_compiled.py long-recursion.bobc ==> #f

python interpret_file.py long-recursion.scm will segfault before the patch python interpret_file.py long-recursion.scm ==> #f after the patch

natethern avatar Oct 01 '25 15:10 natethern

Cleaned-up version of my previous request with improved comments and docstrings.

natethern avatar Oct 01 '25 15:10 natethern