let rec delone el = function [] -> [] h :: t -> if h = el then t else h :: (delone el t) let delall el = List.filter (fun x -> x <> el) let rec delall2 el = function [] -> [] h :: t -> let rest = delall2 el t in if h = el then rest else h :: rest let rec member el = function (* List.mem *) [] -> false h :: t -> h = el or member el t let rec add_end el = function [] -> [el] h :: t -> h :: (add_end el t) let rev = (* List.rev *) let rec rev2 res = function [] -> res h :: t -> rev2 (h :: res) t in rev2 [] let rec iter f = function (* List.iter *) [] -> () h :: t -> (f h; iter f t) let rec map f = function (* List.map *) [] -> [] h :: t -> f h :: map f t ;; delall 5 [1;2;5;6;5;3;5;5];; iter print_int [1;2;3];; map (fun x -> x + 2) [3; 7; 4] ;;
This document was generated using caml2html