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 に答える