diff --git a/Code CAML.md b/Code CAML.md index c11f4f3..a7fbce5 100644 --- a/Code CAML.md +++ b/Code CAML.md @@ -1,2 +1,11 @@ ```Ocaml +let rec insert_post x f = function + | [] -> Failwith "x cannot be inserted" + | e::t -> if f e then e::x::t else y::insert_post x f t;; +let pos_max lst = let x = 1 in match lst with + | [] -> invalid_arg "post_max: empty list" + | e::[] -> e + | e1::e2::t -> if e2 > e1 then + x = x + 1; + e2::pos_max else e1::t;;