-let rec list_nth n = function
- | [] -> raise_error ET.ENoEntry
- | (_,hd)::tl -> if n = 0 then hd else list_nth (pred n) tl
-
-let rec list_select n = function
- | [] -> raise_error ET.ENoEntry
- | (b,hd)::tl -> if n = 0 then (not b,hd)::tl else (b,hd)::list_select (pred n) tl
-
-let rec list_select_all = function
- | [] -> []
- | (b,hd)::tl -> (not b,hd)::list_select_all tl
-
-let rec list_split = function
- | [] -> [], []
- | (b,a) as hd :: tl ->
- let fs,ts = list_split tl in
- if fst hd then fs,((false,a)::ts)
- else (hd::fs),ts
-
-let rec list_find_selected r = function
- | [] -> r
- | (b,hd)::tl ->
- begin match b, r with
- | false, _ -> list_find_selected r tl
- | true , None -> list_find_selected (Some hd) tl
- | true , Some _ -> raise_error (ET.EWrongSelect)
- end
+let rec list_apply prop map n = function
+ | [] -> false
+ | hd :: tl ->
+ if prop n hd then begin map hd; true end
+ else list_apply prop map (succ n) tl
+
+let list_nth map n l =
+ let prop m _ = m = n in
+ if list_apply prop map 0 l then () else raise_error ET.ENoEntry
+
+let list_split prop map l =
+ let lt, lf = List.partition prop l in
+ List.iter map lt; lf, lt