OCaml函数输入问题

时间:2013-10-10 14:53:14

标签: function functional-programming ocaml caml

我正在尝试编写一个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

为什么会出现此错误,我该如何解决?

1 个答案:

答案 0 :(得分:0)

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