Hy, i'm trying to create a histogram but i keep getting an error.
Histogram example:
input :[2;1;2;3;2;1;2;2;5]
output :[(2,5);(1,2);(3,1);(5,1)]
My code:
let rec count a ls = match ls with
|[] -> 0
|x::xs when x=a -> 1 + count a xs
|_::xs -> count a xs
let rec histo l = match l with
|[] -> []
|x :: xs -> [(x, count x l)] @ List.filter(fun x -> xs != x)histo xs;;
Error: This function has type ('a -> bool) -> 'a list -> 'a list It is applied to too many arguments; maybe you forgot a `;'.
List.filter (fun x -> xs != x) (histo xs)- beoliver