Seeing and Doing : Example :

Sorting efficiently

Resorting to general recursion, we can define a better sorting function:

quicksort :: Ord a => [a] -> [a] quicksort [] = [] quicksort (x:xs) = quicksort (filter (<x) xs)++ x: quicksort (filter (>=x) xs)

But this is almost structurally recursive. We only need to get rid of the call to filter in the recursive call to quicksort.