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