Ocaml 入门整理2
来源:互联网 发布:淘宝店名大全女装 编辑:程序博客网 时间:2024/04/30 09:29
Ocaml Standard Library
了解Module
- Structure = implementation of module
- signture = interface of module
signture 有点类似Java 里面的Interface
举个例子
module type STACK =
sig
type 'a t
exception Empty
val empty : 'a t
val push : 'a -> 'a t ->'a t
val pop : 'a t -> 'a * 'a t
end;;
上面的代码是说 Stack 这个Module 具有两个field:type t 和 exception Empty
然后就是3个function: empty, push, pop /
那么STACK 到底是怎么具体实现的呢
module MyStack =struct
type t = int list
exception Empty
let empty = []
let push x t = x :: t
let pop t =
match t with
[] -> raise Empty
|h::t -> (h, t)
let first t =
match t with
[] -> raise Empty
|h::t -> h
end
- Ocaml 入门整理2
- Ocaml 的入门整理 1
- ocaml 2
- 学习Ocaml(2)---基础
- ocaml
- OCaml
- Practical OCaml
- ocaml学习
- OCaml安装
- 【Java】入门知识点整理-2
- Ocaml学习笔记 语句
- Ocaml基本认识
- OCaml样本代码
- OCaml for Haskellers
- Ocaml编程速览
- ubuntu ocaml blast
- Ocaml 中的module system
- 学习ocaml----(3)基础
- 直接通过ODBC 读写Excel表格文件
- 常用数字正则表达式
- CS8900A网卡驱动移植
- 下载了Delphi2010
- 我的母亲
- Ocaml 入门整理2
- 开始写博
- 推荐三篇文章,分别是关于微软企业库、ASP.NET MVC以及SEO优化
- Android 开发环境搭建中--- “An SDK Target must be specified.” 问题解决
- 无意中的发现
- Solaris IP配置
- exec系统调用
- Migrating from VC6 to VC9
- linux帮助命令[man]及退出方法[q]