Skip to content

Instantly share code, notes, and snippets.

@gdejohn
Last active August 29, 2015 14:25
Show Gist options
  • Save gdejohn/3657da88c260250ae32f to your computer and use it in GitHub Desktop.
Save gdejohn/3657da88c260250ae32f to your computer and use it in GitHub Desktop.
choose :: Int -> [a] -> [[a]]
choose 0 _ = [[]]
choose _ [] = []
choose k (x:xs) | k > 0 = map (x:) (choose (k - 1) xs) ++ choose k xs
| otherwise = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment