Created
October 21, 2012 05:00
-
-
Save msysyamamoto/3925899 to your computer and use it in GitHub Desktop.
insertion sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import Test.QuickCheck | |
insertionSort :: Ord a => [a] -> [a] | |
insertionSort = foldr isort [] | |
where | |
isort x [] = [x] | |
isort x (y:ys) | |
| x > y = y : isort x ys | |
| otherwise = x : y : ys | |
prop_insertionSort :: [Int] -> Bool | |
prop_insertionSort xs = insertionSort xs == sort xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment