I implemented a version of this answer https://stackoverflow.com/a/9920425/1261166 (I don't know what was intended by the person answering)
sublistofsize 0 _ = [[]]
sublistofsize _ [] = []
sublistofsize n (x : xs) = sublistsThatStartWithX ++ sublistsThatDontStartWithX
where sublistsThatStartWithX = map (x:) $ sublistofsize (n-1) xs
sublistsThatDontStartWithX = sublistofsize n xs
what I'm unsure of is sublistsThatStartWithX = map (x:) $ sublistofsize (n-1) xs
I assume that map (x:) gives a problem performance wise, but not sure of how to solve it. I've done profiling on print $ length $ sublistofsize 5 $ primesToTakeFrom 50
COST CENTRE MODULE no. entries %time %alloc %time %alloc
sublistofsize Main 112 4739871 46.9 39.9 96.9 100.0
sublistofsize.sublistsThatDontStartWithX Main 124 2369935 2.2 0.0 2.2 0.0
sublistofsize.sublistsThatStartWithX Main 116 2369935 47.8 60.1 47.8 60.1
Did I implement it in a good way? Are there any faster ways of doing it?