昨天的代码令我想起最短的排序算法,当然只针对可枚举的类型:
sort list = [x | x <- [minimum list.. maximum list], elem x list]
测试一下,非常OK!
>> sort [8,5,23,4,5,3,121,324]
[3,4,5,8,23,121,324]
昨天的代码令我想起最短的排序算法,当然只针对可枚举的类型:
sort list = [x | x <- [minimum list.. maximum list], elem x list]
测试一下,非常OK!
>> sort [8,5,23,4,5,3,121,324]
[3,4,5,8,23,121,324]