Advertisement
Guest User

Untitled

a guest
Dec 7th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.30 KB | None | 0 0
  1. List.fold_left (fun (maxelt, maxcount, elt, count) x ->
  2.  
  3. if elt = x then (maxelt, maxcount, elt (count + 1))
  4.         else if (count > maxcount) then (elt, count, x, 1)
  5.         else (maxelt maxcount x 1) in
  6.   match list with
  7.    | [] -> failwith "none"
  8.    | x::xs -> (x, 0, x, 1)
  9.  
  10.  
  11.  
  12. ) [] list;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement