I am trying to write a function in OCaml that takes a predicate, a list of tuples, and the empty list and returns a list of tuples in that original list whose last member satisfies the predicate.
What I have so far is:
let rec find_tuples p l l1 =
match l with
| [] -> []
| (n,s,f) :: t -> if p f then ((n,s,f) :: l1) else find_tuples p t l1
But this only returns the first tuple matching the predicate. What do I change to get it to return all the tuples that match?