diff options
Diffstat (limited to 'tests/lambda.lisp')
| -rw-r--r-- | tests/lambda.lisp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/lambda.lisp b/tests/lambda.lisp index 5c93bdb..18bbd8b 100644 --- a/tests/lambda.lisp +++ b/tests/lambda.lisp @@ -3,10 +3,24 @@ (lambda (g) (funcall g g)) (lambda (h) (funcall f (lambda args (apply (funcall h h) args)))))) + (defun fibo-impl (self) (lambda (n) (if (<= n 2) 1 (+ (funcall self (- n 1)) (funcall self (- n 2)))))) + (defvar fibo (Y #'fibo-impl)) + (assert (= 55 (funcall fibo 10))) + +(defun generate-counter (init) + (let ((i init)) + (lambda () + (setq i (+ 1 i)) + i))) + +(let ((c (generate-counter 0))) + (assert (= 1 (funcall c))) + (assert (= 2 (funcall c))) + (assert (= 3 (funcall c)))) |
