Advertisement
SetKaung

Untitled

Aug 14th, 2024 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 0.23 KB | Source Code | 0 0
  1. orderedInsert :: (Ord a) => [a] -> a -> [a]
  2. orderedInsert [] x = [x]
  3. orderedInsert (x : xs) y = if y <= x then y : x : xs else x : orderedInsert xs y
  4.  
  5. insertionSort :: (Ord a) => [a] -> [a]
  6. insertionSort = foldl orderedInsert []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement