Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Created June 7, 2013 14:53
Show Gist options
  • Save aoeuidht/5729827 to your computer and use it in GitHub Desktop.
Save aoeuidht/5729827 to your computer and use it in GitHub Desktop.
exericse 1.31
(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