我开始学习OCaml语言。你能告诉我为什么这段代码显示错误吗?OCaml:为什么我得到这个错误?
let unite x =
if x < 100 then x mod 10
else if x >= 100 then x mod 100;;
let dizaine x =
if x < 100 then x/10
else if x >= 10 then unite(x/10);;
let centaine x =
if x >= 100 then x/100;;
let somme_chiffre x =
if x >= 100 then unite x + dizaine x + centaine x
else if x > 9 then unite x + dizaine x
else unite x;;
let div3 x = if ((somme_chiffre x) mod 3) = 0 then 1 else 0;;
print_int(div3 32);;
print_string("\n");;
的错误是:文件 “./test.ml”,第3行,字符24-33: 错误:此表达式具有int类型但预期类型 单元
提示:我为Reason项目提出了一个问题,试图改善这个错误,因为坦率地说,这种情况的错误信息是绝对可怕的。如果错误得到改善,它会首先触发Reason/BuckleScript,但是希望整个错误改进项目最终会被OCaml正确地应用。无论如何,请参阅https://github.com/reasonml-community/error-message-improvement/issues/30 – glennsl