Make install.
[Faustine.git] / interpretor / aux.ml
1 (**
2 Module: Aux
3 Description: all auxiliary functions
4 @author WANG Haisheng
5 Created: 12/08/2013 Modified: 13/08/2013
6 *)
7
8
9 let array_map = fun f -> fun a ->
10 let n = Array.length a in
11 Array.init n (fun i -> f a.(i));;
12
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.");;
18
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.");;
25
26 let decorate = fun s -> " Faustine -> " ^ s;;