1

我正在尝试编写一个 Caml 函数,但在打字时遇到了一些麻烦。功能是:

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

为什么会发生此错误,我该如何解决?

4

1 回答 1

0

seedLife 需要 3 个参数,但它只传递了 2 个。

于 2013-10-10T15:24:37.150 回答