0
我正在SML上編寫此函數。它應該列出可能的名字變體(我的名字是維多利亞,V,Vic,Vicky等),並創建{altname1,middle,last},{alt2,middle,last}的記錄。錯誤類型不匹配
因此,這裏是我的代碼:
fun similar_names (substits:, name) =
let
val {first=n1, second=n2, third=n3} = name
fun name_constructor (altnames:string list, acc) =
case altnames of
[] => acc
| a::aa => {first=a, second=n2, third=n3}::acc
in
name_constructor(get_substitutions2(substits, n1),name)
end
get_substitutions2只會給一個名字的所有可能的變化列表(即:字符串列表),和它的作品。
我得到的錯誤是:
a02.sml:65.2-65.58 Error: operator and operand don't agree [tycon mismatch]
operator domain: string list * {first:string, second:'Z, third:'Y} list
operand: string list * {first:string, second:'Z, third:'Y}
in expression:
name_constructor (get_substitutions2 (substits,n1),name)
我不明白爲什麼它單獨記錄清單和錄音之間去。你能幫忙嗎?
可能是一個錯字或複製/粘貼的事情,但編譯器不喜歡'(substits :,名)的晃來晃去......結腸)'。 – Brian