Advertisement
PhyscoKillerMonkey

OCaml - wk5ex3

Oct 29th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.34 KB | None | 0 0
  1. let rec count xs m n = match xs with
  2.   | [] -> n
  3.   | x::xs -> if x = m then count xs m (n+1) else count xs m n;;
  4.  
  5. let rec exclude xs y = match xs with
  6.   | [] -> []
  7.   | x::xs -> if x = y then exclude xs y else [x] @ exclude xs y;;
  8.  
  9. let rec histo xs = match xs with
  10.   | [] -> []
  11.   | x::xs -> histo (exclude xs x) @ [(x, count xs x 1)];;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement