I have a function that selects Cartesian products of lists such that the number of duplicate elements is highest:
import Data.List (nub)
f :: Eq a => [[a]] -> [[a]]
f xss = filter ((==) minLength . length . nub) cartProd
where
minLength = minimum (map (length . nub) cartProd)
cartProd = sequence xss
For example:
*Main> f [[1,2,3],[4],[1,5]]
[[1,4,1]]
But:
*Main> sequence [[1,2,3],[4],[1,5]]
[[1,4,1],[1,4,5],[2,4,1],[2,4,5],[3,4,1],[3,4,5]]
Is there a name for the property that the result of my function f has?