I am writing an OCaml function that accepts a function type, such as (fun _ -> true)
and a list. This is what I currently have:
let drop_until_boolean (x: 'a -> bool) lst =
match lst with
| x -> true
Currently that written statement does not work properly, as it always evaluates to true
.
When I call drop_until_boolean (fun _ -> true) []
I want it to return true
, and when I call drop_until_boolean (fun _ -> true) ["a"]
I want it to return false
.
Question Summary: How do I make a function such that drop_until_boolean (fun _ -> true) []
evaluates to true
.
Another example: drop_until_boolean (fun s -> s.[0]='z') ["z"]
evaluates to true
and drop_until_boolean (fun s -> s.[0]='z') ["y"]
evaluates to false
.