let frequencies list =
if list = [] then invalid_arg "frequencies";
let last_elt,freq,result = List.fold_left
(fun (current_elt,nb,accu) elt ->
if current_elt = elt
then elt, succ nb, accu
else elt, 0, (current_elt,succ nb) :: accu)
(List.hd list, -1, [])
list in
(last_elt,succ freq) :: result