Created
June 7, 2013 14:53
-
-
Save aoeuidht/5729827 to your computer and use it in GitHub Desktop.
exericse 1.31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun product (term a next b) | |
(if (> a b) | |
1 | |
(* (funcall term a) | |
(product term (funcall next a) next b)))) | |
(defun product-iter (term a next b) | |
(defun iter (a result) | |
(if (> a b) | |
result | |
(iter (funcall next a ) (* result (funcall term a))))) | |
(iter a 1)) | |
(product-iter #'(lambda (x) x) 1 #'(lambda (x) (+ x 1)) 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment