【发布时间】:2011-11-03 16:13:55
【问题描述】:
我的排列函数:
有趣的烫发 [] = [[]] |烫发 (x::xs) = 让 有趣的 insertEverywhere [] = [[x]] | insertEverywhere (y::ys) = 让 有趣的 consy 列表 = y::list 在 (x::y::ys) :: (map consY (insertEverywhere ys)) 结尾 在 List.concat (map insertEverywhere (perms xs)) 结尾;输入:
perms [];
输出:
stdIn:813.1-813.9 Warning: type vars not generalized because of
value restriction are instantiated to dummy types (X1,X2,...)
val it = [[]] : ?.X1 list list
有人可以解释为什么类型 var 没有被泛化吗?
需要注意的是,perms的类型是在输入perms后给出的;作为
perms;
val it = fn : 'a list -> 'a list list
所以看起来我已经实现了广义变量,至少对我来说是这样。
【问题讨论】: