let list_remove_first (_predicate: 'a -> bool) (_list: 'a list) : 'a list =
let rec do_list_remove_first (list: 'a list) : 'a list =
match list with
| [] ->
(* no element has been removed, so reuse the old list *)
raise Exit
| head :: tail ->
if _predicate head then
tail
else
head :: do_list_remove_first tail
in
try
do_list_remove_first _list
with
| Exit ->
_list