F# 树
2016-04-08 20:12
267 查看
树1
> type BinTree<'a, 'b> = | Leaf of 'a | Node of BinTree<'a, 'b> * 'b * BinTree<'a, 'b>;; type BinTree<'a,'b> = | Leaf of 'a | Node of BinTree<'a,'b> * 'b * BinTree<'a,'b> > let t1 = Node(Node(Leaf 1, "cd", Leaf 2), "ab", Leaf 3);; val t1 : BinTree<int,string> = Node (Node (Leaf 1,"cd",Leaf 2),"ab",Leaf 3) > let rec depth = function | Leaf _ -> 0 | Node (t1, _, t2) -> 1 + max (depth t1) (depth t2);; val depth : _arg1:BinTree<'a,'b> -> int > depth t1;; val it : int = 2
相关文章推荐
- 链表迭代器
- iOS简单动画效果
- 文章标题
- 密码验证合格程序(华为oj)
- 3、MongoDB数据库集合常用操作
- freemarker生成java代码
- 小米笔试题 风口的猪-中国牛市
- 关于ListView中点击item后背景色不改变,但是事件的确执行了
- hbase family qualifier设置
- HashMap实现原理,利用数组和链表存储元素
- HDU 4283 You Are the One(区间DP)
- 深入理解SQL的四种连接-左外连接、右外连接、内连接、全连接
- 00001--awk取时间段日志
- 扣丁学堂笔记第27天NDK、屏幕适配与APP上线
- iOS滑动条UISlider的使用方法
- busybox中tftp服务器使用命令
- 结对编程之黄金点游戏
- html中的表格 bootstrap-table
- gcc编译选项学习
- 337. House Robber III