Hier die Lösung:
traceBubbleSort :: (Ord a) => [a] -> [[a]]
traceBubbleSort xs
| isSorted (<=) xs = [xs]
| otherwise = traceBubbleSort (moveBubble xs) ++ [xs]
where
moveBubble [] = []
moveBubble [x] = [x]
moveBubble (x:y:rest)
| x <= y = x: moveBubble (y:rest)
| otherwise = y: moveBubble (x:rest)
isSorted f (x:y:xs)
| f x y = isSorted f (y:xs)
| otherwise = False
isSorted _ _ = True
Punkte: 35