Skip to content

Instantly share code, notes, and snippets.

@cls
Created February 21, 2017 11:09
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 cls/822370cc18197c158fbebffba814be89 to your computer and use it in GitHub Desktop.
Save cls/822370cc18197c158fbebffba814be89 to your computer and use it in GitHub Desktop.
Cartesian product over lists
cartesian :: [[a]] -> [[a]]
cartesian [] = [[]]
cartesian (xs:zss) = [x:ys | x <- xs, ys <- cartesian zss]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment