次の関数は、空のリストを照合しようとした時点でコンパイルエラーを出します。
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
これは、がタプルではなくsのremaining
単純なリストである場合に正常に機能します。int
タプルの空のリストを一致させるにはどうすればよいですか?