.. n) (1 .. n) > pairs 3 [1,2,3,1,2,3,1,2,3] > let pairs' n = concatMap (\i -> map (\j -> [i, j]) (1 .. n)) (1 .. n) > pairs' 3 [[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]] > let pairs'' n = concatMap (\i -> map (\j -> [i, j]) (i .. n)) (1 .. n) > pairs'' 3 [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]] > import Data.Foldable > let factors n = filter (\pair -> product pair == n) (pairs'' n) > factors 10 [[1,10],[2,5]] Reduces a list of Ints down to their product. (e.g., product [1, 2, 3, 4] returns 24)