From d541e0f84ae8f82f70e2393207d359975841facf Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 20 Nov 2019 22:47:52 +0100 Subject: lambdarec for singly-recursive lambda's --- tests/lambdarec.lisp | 6 +++++- tests/lambdarec.out | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/lambdarec.out (limited to 'tests') diff --git a/tests/lambdarec.lisp b/tests/lambdarec.lisp index 69b830c..a6caa55 100644 --- a/tests/lambdarec.lisp +++ b/tests/lambdarec.lisp @@ -1,6 +1,10 @@ +#include "stdlib.lisp" + (define fibo (n) (let ((helper (lambdarec rec (m a b) - (if (= m n) b (rec m b (+ a b)))))) + (if (= m n) b (rec (+ m 1) b (+ a b)))))) (if (<= n 0) 0 (if (<= n 2) 1 (helper 2 1 1))))) + +(for 1 25 (lambda (i) (print (fibo i)))) diff --git a/tests/lambdarec.out b/tests/lambdarec.out new file mode 100644 index 0000000..14950e3 --- /dev/null +++ b/tests/lambdarec.out @@ -0,0 +1,25 @@ +1 +1 +2 +3 +5 +8 +13 +21 +34 +55 +89 +144 +233 +377 +610 +987 +1597 +2584 +4181 +6765 +10946 +17711 +28657 +46368 +75025 -- cgit v1.2.3-54-g00ecf