下面描述的模块的目的是实现一个模块,该模块一旦由整数 n 启动,就会根据 n 的值执行所有操作。
module ReturnSetZero =
functor ( Elt : int ) ->
struct
let rec sublist b e l =
match l with
[] -> failwith "sublist"
| h :: t ->
let tail = if e = 0 then [] else sublist (b - 1) (e - 1) t in
if b > 0 then tail else h :: tail
let rec zerol = 0:: zerol
let zeron = sublist 0 n zerol
(*other operations based on n which is selected once when the module is initialized*)
end;;
错误:未绑定的模块类型 int
这里有什么问题?是否有更有效/更直观的替代实现?