Skip to content

Instantly share code, notes, and snippets.

@hyphenrf
Created June 15, 2021 11:28
Show Gist options
  • Save hyphenrf/614a56723dd16fe6a409d0cd2253b265 to your computer and use it in GitHub Desktop.
Save hyphenrf/614a56723dd16fe6a409d0cd2253b265 to your computer and use it in GitHub Desktop.
you've heard of permutations, get ready for this
-- possibly the worst implementation out there but
combinations [] = []
combinations xs = go (length xs) (map pure xs) xs where
go 1 zs __ = zs
go n zs ys = [ y:z | y <- ys, z <- go (n-1) zs ys ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment