Skip to content

Commit e2e2915

Browse files
committed
Added an example to illustrate how husk-scheme implements proper tail recursion.
1 parent 978e1df commit e2e2915

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/tco.scm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; This example proves that a Scheme implements proper tail recursion (or tail call optimization, or TCO).
2+
;
3+
; TCO isn't just about self-calling. The following is expected to run forever in scheme. It will use ~100% CPU, however memory usage is expected to remain constant and a stack overflow should never occur:
4+
;
5+
(define (foo) (bar))
6+
(define (bar) (foo))
7+
(foo)

0 commit comments

Comments
 (0)