Skip to content

Instantly share code, notes, and snippets.

@naohaq
Last active May 28, 2018 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naohaq/c8fcabedb52f25006f543a045b819b5e to your computer and use it in GitHub Desktop.
Save naohaq/c8fcabedb52f25006f543a045b819b5e to your computer and use it in GitHub Desktop.
Generate the list of all combinations.
comb_0_1 :: (Num a) => Int -> [[a]]
comb_0_1 n | n >= 0 = f [[]] n
| otherwise = []
where f xs 0 = xs
f xs n = f [(b:x) | b<-[0,1], x<-xs] (n-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment