X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83..4745d0cba82b458d491320c72e564b23899a5310:/interpreter/aux.ml?ds=sidebyside diff --git a/interpreter/aux.ml b/interpreter/aux.ml index 7c21a61..4709724 100644 --- a/interpreter/aux.ml +++ b/interpreter/aux.ml @@ -18,7 +18,7 @@ let array_map3 = fun f -> fun a -> fun b -> fun c -> if n1 = n2 && n1 = n3 then Array.init n1 (fun i -> f a.(i) b.(i) c.(i)) else raise (Invalid_argument "Array.map3 size not matched.");; -let decorate = fun s -> " Faustine -> " ^ s;; +let decorate = fun s -> " Faustine -> " ^ s ^ "\n";; let xor : bool -> bool -> bool = fun a -> fun b -> (a || b) && (not (a && b));; @@ -34,3 +34,15 @@ let remainder_float : float -> float -> float = if (abs_float r) > ((abs_float f2) /. 2.) then (if r *. f2 > 0. then (r -. f2) else (r +. f2)) else r;; + +let format_of_file : string -> string = + fun (path : string) -> + let fragments = Str.split (Str.regexp "\.") path in + let n = List.length fragments in + List.nth fragments (n - 1);; + +let transpose : int -> 'a array array -> 'a array array = + fun width -> fun matrix -> + let get_element = fun i -> fun array -> array.(i) in + let get_column = fun m -> fun i -> Array.map (get_element i) m in + Array.init width (get_column matrix);; \ No newline at end of file