Seeing and Doing :

Example: sorting by structural recursion

Sorting is easy to define with structural recursion:

insert :: Ord a => a -> [a] -> [a] sort :: Ord a => [a] -> [a] insert x [] = [x] insert x (y:ys) = if x<=y then x:y:ys else y:insert x ys sort [] = [] sort (x:xs) = insert x (sort xs)

However, there are more efficient sorting algorithms...