diff options
| author | Mistivia <i@mistivia.com> | 2025-06-21 20:20:12 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-21 20:23:24 +0800 |
| commit | 1cf7adef90777698d1f17363a5f82c997d5f1c34 (patch) | |
| tree | ae10b7efd3dc3d20a4f798849b5edaf1a31cc47f /tests/tailcall.lisp | |
| parent | 249700617406474c5b60df2aa66a2a9951603e3c (diff) | |
fix tco bug
Diffstat (limited to 'tests/tailcall.lisp')
| -rw-r--r-- | tests/tailcall.lisp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/tailcall.lisp b/tests/tailcall.lisp new file mode 100644 index 0000000..8cea496 --- /dev/null +++ b/tests/tailcall.lisp @@ -0,0 +1,17 @@ +(defun is-even (x) + (if (= x 0) + #t + (is-odd (- x 1)))) + +(defun is-odd (x) + (is-even (- x 1))) + +(assert (is-even 10000)) +(assert (is-even 10)) +(assert (is-even 0)) +(assert (is-odd 1)) +(assert (is-even 2)) + +;; can pass without stack overflow, +;; but comment out for too time-consuming +;; (assert (is-even 1000000)) |
