[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reduce should allow an accessor function to be specified
- To: common-lisp@Think.COM
- Subject: reduce should allow an accessor function to be specified
- From: Mark Bromley <bromley@Think.COM>
- Date: Sat, 14 Nov 87 04:38:32 est
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).