Page 160 - Algorithms Notes for Professionals
P. 160
Chapter 31: Insertion Sort
Section 31.1: Haskell Implementation
insertSort :: Ord a => [a] -> [a]
insertSort [] = []
insertSort (x:xs) = insert x (insertSort xs)
insert :: Ord a => a-> [a] -> [a]
insert n [] = [n]
insert n (x:xs) | n <= x = (n:x:xs)
| otherwise = x:insert n xs
colegiohispanomexicano.net – Algorithms Notes 156