파일의 각 문자 수를 얻기 위해 OCaml에서이 문자를 작성하기 시작했습니다. 내가 ocamlc -c
로 컴파일 할 때구문 오류 OCaml
open Hashtbl;;
type 'a option = None | Some of 'a;;
let rec charCount fd ht =
let x =
try Some (input_char fd)
with End_of_file -> None
in
match x with
| Some c ->
let val =
try find (ht c)
with Not_found -> 0
in
replace ht c (val+1);
charCount fd ht
| None ->();;
let ht = create 0;;
let loadHisto fn =
let fd = open_in fn
in
charCount fd ht;;
loadHisto "testfile";;
iter printf("%s => %s\n") ht;;
내가 메시지를 얻을 :
Error: Syntax error:
을 사용할 수 없습니다 'Hashtbl' 모듈을 실제 코드로 열지 말 것을 권합니다. 이것이 그 의도 된 용도라면, 그 기능은 덜 일반적인 이름을 가질 필요가 있습니다. –