let of_list l = let lr = ref l in let f _ = match !lr with | h :: t -> lr := t ; Some h | [] -> None in from f