我试图定义一个 SML 函数,它将两个列表压缩为一个:
fun zip(vs:string list, ps:int list) : string*int list =
case (vs,ps) of
(v::vv,p::pp) => (v,p) :: zip(vv,pp)
| _ => []
但它报告了这样的错误:
stdIn:3.20-3.39 Error: operator and operand don't agree [tycon mismatch]
operator domain: (string * int) * (string * int) list
operand: (string * int) * (string * int list)
in expression:
(v,p) :: zip (vv,pp)
我无法理解错误,也找不到我的功能错误在哪里。
如何解决?