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

  • 關於本站
  • 免責聲明