[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reduce should allow an accessor function to be specified
Currently, the function is directly applied to the elements of the sequence.
This limits the utility of reduce. Summing the cars of a sequence of conses is
cumbersome using reduce, and is possible only because numbers can be
distinguished from conses at run time. E.g.
(reduce #'(lambda (a b) (+ (if (consp a) (car a) a) (if (consp b) (car b) b))) sequence)
It would be much more natural to be able to use the following
(reduce #'+ sequence :key #'car).