3 Description: all auxiliary functions
5 Created: 12/08/2013 Modified: 13/08/2013
10 let array_map2 = fun f -> fun a -> fun b ->
11 let n1 = Array.length a in
12 let n2 = Array.length b in
13 if n1 = n2 then Array.init n1 (fun i -> f a.(i) b.(i))
14 else raise (Invalid_argument "Array.map2 size not matched.");;
16 let array_map3 = fun f -> fun a -> fun b -> fun c ->
17 let n1 = Array.length a in
18 let n2 = Array.length b in
19 let n3 = Array.length c in
20 if n1 = n2 && n1 = n3 then Array.init n1 (fun i -> f a.(i) b.(i) c.(i))
21 else raise (Invalid_argument "Array.map2 size not matched.");;