- (SUMMING [(INITIAL <initial-sum>)] ...)syntax
- (MULTIPLYING [(INITIAL <initial-sum>)] ...)syntax
Usage:
(FOR <result> (SUMMING [(INITIAL <initial-sum>)] ...)) (FOR <result> (MULTIPLYING [(INITIAL <initial-product>)] ...))
Accumulates sums or products by adding the accumulated data to <initial-sum>, or multiplying the accumulated data by <initial-product>.
<Initial-sum> and <initial-product>, if supplied, must be numbers, and are evaluated once before the loop begins. The default value of <initial-sum> is 0, and the default value of <initial-product> is 1.
<Result> is a loop variable.
(define (count predicate list) (loop ((for elt (in-list list)) (for count (summing 1 (if (predicate elt))))) => count))