長さ関数を持つ hello.ml があります。
let rec length l =
match l with
[] -> 0
| h::t -> 1 + length t ;;
関数を使用する call.ml:
#use "hello.ml" ;;
print_int (length [1;2;4;5;6;7]) ;;
インタープリターモード(ocaml)ではocaml call.ml
結果を取得するために使用できますが、ocamlcまたはocamlbuildでコンパイルしようとすると、コンパイルエラーが発生しました。
File "call.ml", line 1, characters 0-1:
Error: Syntax error
次に、呼び出し元、呼び出し先、およびビルド コマンドを変更して、コードを実行可能ファイルにコンパイルする方法を教えてください。