+(defun reduce-iterator (func init iter)
+ "Invoke FUNC on the elements of ITER.
+
+ We maintain a STATE whose value initially is INIT; for each ITEM, we
+ update the state with the value of (funcall FUNC ITEM STATE); the end
+ result is the final state."
+ (let ((state init) item)
+ (loop
+ (setf (values item iter) (funcall iter))
+ (unless iter (return state))
+ (setf state (funcall func item state)))))
+