Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. import Data.Set (Set)
  2. import qualified Data.Set as Set
  3.  
  4. kSubsetPermutations :: Ord a => Int -> Set a -> [[a]]
  5. kSubsetPermutations 0 _ = []
  6. kSubsetPermutations 1 xs = map (\x -> [x]) $ Set.toList xs
  7. kSubsetPermutations k xs = concatMap f $ Set.toList xs where
  8. f x = map (x :) $ kSubsetPermutations (k-1) $ Set.delete x xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement