0
結果を返す前に、結果のすべての要素をログに記録したいと思います。それを達成する方法はありますか?リストを返す前にOcamlでリストのすべての要素を記録するにはどうすればいいですか?
let calculate ~size_of_experiment:s ~number_of_buckets:n =
let results = run_experiments s n in
List.iter (fun x -> print_endline x) results;
List.fold_left (fun x y -> x + (snd y)) 0 results
上記のコードはコンパイルされません:
Error: This expression has type (int * int) list
but an expression was expected of type string list
Type int * int is not compatible with type string
ありがとう@jeffrey私はOcamlについてのこの詳細を完全に忘れてしまった。 – Istvan