Consider the type signature of List.fold_right
:
# List.fold_right;;
- : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b = <fun>
Three arguments are taken. You've only passed one.
List.fold_right
and List.fold_left
consider an initial value and each element of the input list and runs a function on them to generate the initial value for the next iteration, returning that value at the end of the list.
What do you think the "update" and the initial values should be in the following to implement the functionality you want?
List.fold_right (fun x init -> ...) [true; false; false] ...
Note 1: I would use List.fold_left
as it is tail-recursive, though for a small dataset it is unlikely to make a practical difference here.
Note 2: if h then true else false
is equivalent to h
.