0
我的置換函數:爲什麼當一個空列表被傳入時,我的排列函數會給我一個警告?
fun perms [] = [[]] | perms (x::xs) = let fun insertEverywhere [] = [[x]] | insertEverywhere (y::ys) = let fun consY list = y::list in (x::y::ys) :: (map consY (insertEverywhere ys)) end in List.concat (map insertEverywhere (perms xs)) end;
輸入:
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
有人可以解釋爲什麼類型瓦爾不是一概而論?
我應該注意,燙髮類型是在輸入燙髮後給出的;作爲
perms;
val it = fn : 'a list -> 'a list list
所以看起來我已經至少達到廣義變量,對我來說。