Reduce in Lisp

The function reduce applies a specified function to the first two elements of a list, then to the result of the first two and the third element, and so forth.


>(reduce '+ '(1 2 3 17))

23

>(reduce '* '(1 2 3 17))

102

reduce is just what we need to process a result from mapcan:


>(reduce '+ (mapcan 'testforz
                    '(z m u l e z r u l e z)))

3

Contents    Page-10    Prev    Next    Page+10    Index