Package: alexandria

Function map-combinations

Lambda List

map-combinations (function sequence &key start end length copy)

Details

Calls function with each combination of length constructable from the elements of the subsequence of sequence delimited by start and end.

start defaults to 0, end to the length of sequence, and length to the length of the delimited subsequence. (So unless length is specified there is only a single combination, which has the same elements as the delimited subsequence.) If copy is true (the default) each combination is freshly allocated. If copy is false all combinations are eq to each other, in which case consequences are unspecified if a combination is modified by function.

Examples

 (map-combinations #'print '(a b c d) :length 3) => (A B C D)
   (A B C)
   (A B D)
   (A C D)
   (B C D)    
2012-12-9