Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sortedInsert :: (Ord a) => [a] -> a -> [a]
- sortedInsert [] a = [a]
- sortedInsert l@(x: xs) a
- | a > x = [x] ++ sortedInsert xs a
- | otherwise = [a] ++ l
- insSort :: (Ord a) => [a] -> [a]
- insSort l = foldl sortedInsert [] l
- main = do
- let us = [23, 9, 8, 3, 1, 23, 435]
- let st = insSort us
- putStrLn $ show st
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement