Subj : Re: any function to handle this kind of counting? To : comp.programming From : Jon Harrop Date : Sat Jul 30 2005 04:56 am Jon Harrop wrote: > Here is an array-based implementation: let ab = Array.of_list (List.combine a b) in let max_a = ref 0 and max_b = ref '\000' in Array.iter (fun (a, b) -> max_a := max !max_a a; max_b := max !max_b b) ab; let max_a = !max_a and max_b = int_of_char !max_b in let m = Array.init (max_a + 1) (fun _ -> Array.init (max_b + 1) (fun _ -> ref 0)) in Array.iter (fun (a, b) -> incr m.(a).(int_of_char b)) ab; -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com .