logo
  • 教程列表
  • SO官方文档
  • 插入排序
    • Haskell 实现
    • 算法基础
    • C 实现
  1. StackOverflow 文档
  2. algorithm 教程
  3. 插入排序
  4. Haskell 实现

Haskell 实现

Created: November-22, 2018

insertSort::Ord a => [a] -> [a]
insertSort [] = []
insertSort (x:xs) = insert x (insertSort xs)

insert::Ord a => a-> [a] -> [a]
insert n [] = [n]
insert n (x:xs) | n <= x    = (n:x:xs)
                | otherwise = x:insert n xs
  • 算法基础
  • 插入排序

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明