I want to implement the nested functions which are recursive. How to do that? I am getting an error in the following code "an operator expected"
let powerset_cf f1 = if (let rec f lst = match lst with
[] -> true
| h::t -> if (f1 h) then (f t)
else false ) then true
else false;;
Here, lst = any list (e.g [1;2;3]) f1 any characteristic function which returns true if the element is in the set defined by characteristic function. (e.g. let f1 x = (x mod 3 == 0 && x<=15);; ) The powerset_cf function returns true if the lst is the member of the power set of the characteristic function.
Please help fixing this. Thanks in advance.
let rec
should be alet rec
...in
... and you are lacking thein
... part. BTW, be sure to indent properly (for readability reasons) your code. – Basile Starynkevitch