我在“module usingTable:TABLE=”行中遇到语法错误,当我尝试在oCaml中运行此代码时,usingTable一词被突出显示为红色。我想创建如下执行示例所示格式的表。它怎么了?我使用的环境是
https://try.ocamlpro.com/fun-demo/tryocaml_index.html#path%3Dtries
因为我不明白如何在windows中使用cygwin或oCaml Bash。
module type TABLE =
sig
type table
val emptyTable : table
val printTable : table -> string
val create_table : string * string list * (string list) list -> table
end;;
module usingTable : TABLE =
struct
let emptyTable = ()
let table = (string * (string * string list) list)
let rec printTable aTable = match aTable with
()->""
| (title, [data]) -> "\n"^title^"\n\n"^printTable(data)
| [(col,cont)::t] -> col^" "^printTable([t])
end;;
let atable = usingTable.emptyTable;;
let atable = ("Student", [("Id", ["2";"4";"7";"9"]);
("Name", ["Jim";"Linnea";"Steve";"Hannah"]);
("Gender",["Male";"Female";"Male";"Female"]);
("Course",["Geography";"Economics";"Informatics";"Geography"])
]);;
print_string (usingTable.printTable atable) ;;