以下函数在我尝试匹配空列表时给出编译错误:
let rec tuplesToList (acc: int list) (remaining: int*int list) =
match remaining with
| [] -> acc
| (a, b) :: tail -> tuplesToList (a :: b :: acc)
错误是:
This expression was expected to have type int * int list but here has type 'a list
remaining
当是一个简单的int
s 列表而不是元组时,这很好用。如何匹配一个空的元组列表?