I am trying to make function restric that would restrict a table's values according to columns that have value [value]. My idea is to make a list consisting of trues and falses for the column that satisfy condition column and value parameters. Later on recursive match would chose the columns and a listmaker function would make a new column according to true falses list.
When it comes to storing in ocaml nested variables, let...in scoping I am very confused. What is wrong with the code bellow?
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