Haskell经典算法和问题搜集
来源:互联网 发布:易语言编程 编辑:程序博客网 时间:2024/06/05 10:29
快速排序
quick_sort [] = []quick_sort (x:[]) = [x]quick_sort (x:xs) = let smaller_or_equal_list = [a| a<-xs, a<=x] larger_list = [a| a<-xs, a>x] in quick_sort smaller_or_equal_list ++ [x] ++ quick_sort larger_list
插入排序
iSort :: [Integer] -> [Integer]iSort [] = []iSort (x:xs) = ins x $ iSort xsins :: Integet -> [Integer] -> [Integer]ins x [] = [x]ins x (y:ys) | x <= y = x : y : ys | otherwise = y : ins x ys
八皇后
main = print $ queens 8boardSize = 8queens 0 = [[]]queens n = [ x : y | y <- queens (n-1), x <- [1..boardSize], safe x y 1] where safe x [] n = True safe x (c:y) n = and [ x /= c , x /= c + n , x /= c - n , safe x y (n+1)]
0 0
- Haskell经典算法和问题搜集
- 经典算法搜集
- 人工智能经典问题搜集
- cuda计算经典问题搜集
- 数据结构若干经典问题和算法 (收藏)
- 搜集的computer vision网址和算法
- 算法搜集
- 【算法结构】一些经典的算法和数据结构的问题
- 海量数据问题和解决方案搜集汇总
- 海量数据问题和解决方案搜集汇总
- 海量数据问题和解决方案搜集汇总
- 问题搜集
- 问题搜集
- 经典代码片段搜集
- 经典面试题搜集
- 经典面试题搜集
- 经典 回复 搜集 乐一乐
- 算法基础经典问题
- IOS股票App,股精灵
- xdcms更换百度编辑器
- 第九周项目2—对称矩阵压缩存储的实现与应用
- 原SLICK3.0 MySQL InnoDB Driver
- 虚幻4 Event、CustomEvent、EventDispatcher
- Haskell经典算法和问题搜集
- AndroidTest
- MVC框架
- C++ main函数 argc,argv传递参数的含义
- 【LeetCode从零单刷】Symmetric Tree
- Java jdk配置
- POJ 2406 Power Strings (kmp求周期)
- Java鼠标监听(单击、双击、滑轮)
- Linux中环境变量文件及配置