Advertisement
Guest User

Untitled

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