Adding new source file faustio.ml, including class waveio and class csvio.
[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
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.");;
15
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.");;