Teilfolgen der Länge n aus der Listenleistung

Ich habe eine Version dieser Antwort implementierthttps://stackoverflow.com/a/9920425/1261166 (Ich weiß nicht, was von der antwortenden Person beabsichtigt war)

sublistofsize 0 _        = [[]]
sublistofsize _ []       = []
sublistofsize n (x : xs) = sublistsThatStartWithX ++ sublistsThatDontStartWithX
  where sublistsThatStartWithX = map (x:) $ sublistofsize (n-1) xs
        sublistsThatDontStartWithX = sublistofsize n xs

was ich mir nicht sicher bin istsublistsThatStartWithX = map (x:) $ sublistofsize (n-1) xs

Ich gehe davon aus, dass map (x :) ein Problem in Bezug auf die Leistung angibt, aber nicht sicher ist, wie es zu lösen ist. Ich habe ein Profil erstelltprint $ 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

Habe ich es gut umgesetzt? Gibt es schnellere Möglichkeiten?

Antworten auf die Frage(3)

Ihre Antwort auf die Frage