【发布时间】:2018-05-15 23:35:46
【问题描述】:
我正在尝试根据具有值 [value] 的列来限制表的值的函数 retric。我的想法是为满足条件列和值参数的列制作一个由真假组成的列表。稍后递归匹配将选择列,listmaker 函数将根据真假列表创建一个新列。
当谈到存储在 ocaml 嵌套变量中时,让...在范围界定中我很困惑。下面的代码有什么问题?
let rec restrict (column, value, aTable) = match aTable with
name,[]->[]
|name,(col,vals)::rest->if col=column
then (col,auxListMaker(vals,trueFalseList))::restrict (column,value.(name,rest))
else restrict (column,value.(name,rest))
let rec auxTrueFalser (column, value, aTable) = match aTable with
name,[]->[]
|name,(col,vals)::rest-> if column=col
then (if List.hd vals = value
then true::aux1(column,value,(name,[(col,List.tl vals)]))
else false::aux1(column,value,(name,[(col,List.tl vals)])))
else aux1(column,value,(name,rest))
in
let trueFalseList = auxTrueFalser (column, value, aTable) in
let rec auxListMaker (vals, trueFalseList) = match vals with
[]->[]
|h::t -> if List.hd trueFalseList
then h::auxListMaker(t,List.tl trueFalseList)
else auxListMaker(t,List.tl trueFalseList)
in
【问题讨论】:
标签: syntax-error ocaml