有两个功能; funA 和 funB 。 a.i,a.o,ah,w,c
是函数 funA 中的数组。函数 funA 应该作为功能参数传递给函数 funB ,并且数组应该可以由函数 funB 访问。不幸的是,语法检查器遇到错误“错误:未绑定记录字段a”。请发表评论,如何在OCaml / ReasonmL中声明功能参数?
完整列表
module Test = {
let vector = Array.init;
let matrix = (m,n,f) => vector(m,i => vector(n,f(i)));
let length = Array.length;
let rand = (x0,x1) => x0 +. Random.float(x1 -. x0);
let funA = (ni,nh,no) => {
let init = (fi,fo) => {
let i = matrix(ni + 1,fi);
let o = matrix(nh,no,fo);
();
};
let a = {
let i = vector(ni + 1,_ => 1.0);
let o = vector(no,_ => 1.0);
();
};
let ah = vector(nh,_ => 1.0);
let w = init((_,_) => rand(-0.2,0.4),(_,_) => rand(-2.0,4.0));
let c = init((_,_) => 0.0,_) => 0.0);
();
};
let funB = (net,inputs) => {
let (ni,no) = (
length(net.a.i),length(net.ah),length(net.a.o),);
();
};
};