Blob
1 (defun product (term a next b)2 (if (> a b)3 14 (* (funcall term a)5 (product term (funcall next a) next b))))6 (defun factorial (n)7 (product #'identity 1 #'1+ n))8 (defun wallis-pi (n)9 (defun wallis-term (k)10 (let ((nom11 (if (evenp k)12 (+ k 2)13 (+ k 1)))14 (denom15 (if (evenp k)16 (+ k 1)17 (+ k 2))))18 (float (/ nom denom))))19 (* (product #'wallis-term 1 #'1+ n)))21 (defun product-iter (term a next b)22 (defun iter (a result)23 (if (> a b)24 result25 (iter (funcall next a)26 (* (funcall term a) result))))27 (iter a 1))