[英]OCaml function typing issue
我正在尝试编写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
为什么会发生此错误,我该如何解决?
seedLife接受3个参数,但仅传递了2个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.