Created
April 7, 2022 12:32
-
-
Save jayendra13/a16af04a5779e48207c7a3c6106330dd to your computer and use it in GitHub Desktop.
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
module Main where | |
-- http://files.farka.eu/pub/AC21007/lec5.pdf | |
insSortImpl :: [Int] -> [Int] -> [Int] | |
insSortImpl sorted [] = sorted | |
insSortImpl sorted (x:xs) = | |
insSortImpl (insert x sorted) xs | |
where | |
insert y [] = [y] | |
insert y (z:zs) = if y < z | |
then y : (z:zs) | |
else z : (insert y zs) | |
insSort :: [Int] -> [Int] | |
insSort x = insSortImpl [] x | |
main = print(insSort [8,7,1,6]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment