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