1
我正在嘗試編寫一個Caml函數,並且在打字時遇到了一些麻煩。該功能是:OCaml函數打字問題
let new_game size count gens =
let rec continueGame board = function
0 ->()
|n -> drawBoard board size;
continueGame (nextGeneration board) (n-1)
in
continueGame (seedLife (matrix 0 size) count) (gens) ;;
以下是其他功能的類型:
val drawBoard : int list list -> int -> unit = <fun>
val seedLife : int list list -> int -> int -> int list list = <fun>
val nextGeneration : int list list -> int list list = <fun>
val matrix : 'a -> int -> 'a list list = <fun>
當試圖評估new_Game
我有以下錯誤:
continueGame (seedLife (matrix 0 size) count) (gens);;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type int -> int list list
but is here used with type int list list
爲什麼這個錯誤發生的歷史和我該如何解決它?
哦謝謝沒有看到thx :) – user26830