Package: alexandria

Function map-derangements

Lambda List

map-derangements (function sequence &key start end copy)

Details

Calls function with each derangement of the subsequence of sequence denoted by the bounding index designators start and end.

Derangement is a permutation of sequence where no element remains in place. sequence is not modified, but individual derangements are eq to each other. Consequences are unspecified if calling function modifies either the derangement or sequence.

Examples

 (map-derangements #'print '(a b c))
   (C A B) 
   (B C A) 
   (A B C)    
2012-12-9