【发布时间】:2013-01-15 00:28:05
【问题描述】:
我有这个函数可以生成一个字符串列表:
fun get_substitutions1 ([],_) = []
| get_substitutions1 (x::xs,s) = case all_except_option(s,x) of
NONE => [] @get_substitutions1(xs,s)
| SOME lst => lst @get_substitutions1(xs,s)
这个函数接受一个字符串列表和一个类型:
fun similar_names(slist,full_name:{first:string,middle:string,last:string})=
let
fun aux(slist,acc)=
case full_name of
{first=a,middle=b,last=c} => case get_substitutions1(slist,a) of
[] => full_name::acc
| x::xs' => full_name:: aux(xs',{first=x,middle=b,last=c}::acc)
in aux(slist,[])
end
我得到一个错误:
错误:运算符和操作数不一致。 运算符域:字符串列表列表 * {first:string, last:string, middle:string} 列表 操作数:字符串列表 * {first:string, last:string, middle:string} 列表 表达: 辅助 (xs',{first=x,middle=b,last=c}::acc)还有其他方法吗?
【问题讨论】:
标签: sml