插入排序 (haskell)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了插入排序 (haskell)相关的知识,希望对你有一定的参考价值。

insert a [] = [a]
insert a (x1:xs)
               | x1 > a = a:x1:xs
               | otherwise = x1:insert a xs
sort [] = []
sort (a1:ax) = insert a1 (sort ax)
main = do
       print $ sort [10,2,432,5436]

 

以上是关于插入排序 (haskell)的主要内容,如果未能解决你的问题,请参考以下文章