12345678910111213141516171819 |
- (defun new-next-fibo-generator ()
- (let ((x0 0)
- (x1 1))
- (lambda ()
- (let ((next (+ x0 x1)))
- (setf x0 x1)
- (setf x1 next)
- next))))
- (defvar *uplimit* 4000000)
- (let ((next-fibo (new-next-fibo-generator))
- (sum 0))
- (do ((x (funcall next-fibo) (funcall next-fibo)))
- ((> x *uplimit*) sum)
- (setf sum (if (evenp x)
- (+ sum x)
- sum)))
- (format t "~&~S" sum))
|