(** [filter] *)
Fixpoint filter (l:list A) : list A :=
match l with
| [] => []
| x :: l => if f x then x::(filter l) else filter l
end.

Lemma forallb_filter_id l: forallb l = true -> filter l = l.
Fixpoint find (l:list A) : option A :=
match l with
| [] => None
| x :: tl => if f x then Some x else find tl
end.