OCaml - Implement nested functions -


i want implement nested functions recursive. how that? getting error in following code "an operator expected"

let powerset_cf f1 = if (let rec f lst = match lst                                    [] -> true                                   | h::t ->  if (f1 h) (f t)                                               else false ) true                      else false;; 

here, lst = list (e.g [1;2;3]) f1 characteristic function returns true if element in set defined characteristic function. (e.g. let f1 x = (x mod 3 == 0 && x<=15);; ) powerset_cf function returns true if lst member of power set of characteristic function.

please fixing this. in advance.

let powerset_cf f1 lst =   let rec f lst =      match lst       | []   -> true       | h::t ->  if f1 h f t else false   in   if f lst true else false ;; 

of course can simplify code, that's not question asked.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -