chickadee » transducers » collect-sum

collect-sum #!optional (sentinel 0)procedure
collect-product #!optional (sentinel 1)procedure

These collectors will compute the sum / product of the items being transduced, as if by applying + or * respectively to the arguments.

 
(import transducers)

(transduce list-fold
           values
           (collect-sum 100)
           (list 2 4 6))

; => 112

(transduce list-fold
           values
           (collect-product -1)
           (list 1 3 5))

; => -15