Cartesian cross product of one or more lists
Download (right click, save as, rename as appropriate)
1 2 3 4 5
-- |@cross list@ returns the list of all lists that are formed by taking one -- element from each sublist of @list@. cross :: [[a]] -> [[a]] cross [] = [[]] cross (x:xs) = [a : b | a <- x, b <- cross xs]