ML 趣题:树的类型

这道也是老题了。(下面我们用OCaml作代码示例,SML或Haskell完全类似。)
- 请用 Leaf 和 Node 这两个 constructors (i.e., variants) 来定义一个二叉树类型,使得以下表达式
number和·tree可以通过类型检测 - 写出在这种定义下
number的具体类型,并解释为什么
- Login to post comments
- 254 reads
Fri, 2008/10/10 - 11:13 — fishmacs

这样也可以?
...... full content is only available to community members.
- Login to post comments
Fri, 2008/10/10 - 11:16 — fishmacs

我以为只有动态语言能这么搞
...... full content is only available to community members.
- Login to post comments
Sun, 2008/10/12 - 00:09 — roy_hu

答案什么时候公布?
...... full content is only available to community members.
- Login to post comments
Sun, 2008/10/12 - 18:17 — code17

第一问的答案
...... full content is only available to community members.
- Login to post comments
Mon, 2008/10/13 - 00:01 — roy_hu

哎,差了点
...... full content is only available to community members.
- Login to post comments
Mon, 2008/10/13 - 04:44 — roy_hu

还要颠倒类型变量的顺序。。
...... full content is only available to community members.
- Login to post comments
Wed, 2008/12/03 - 13:38 — fishmacs

不是很明白
...... full content is only available to community members.
- Login to post comments
Wed, 2008/12/03 - 15:51 — roy_hu

因为5个类型变量被unify了
...... full content is only available to community members.
- Login to post comments
Thu, 2008/12/04 - 00:37 — code17

polymorphic recursion
...... full content is only available to community members.
- Login to post comments
|
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |