2013-10-10 81 views
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 

爲什麼這個錯誤發生的歷史和我該如何解決它?

回答

0

seedLife需要3個參數,但它只能通過2.

+0

哦謝謝沒有看到thx :) – user26830