Nested vectors are implemented, including parser and class nstio.
[Faustine.git] / interpreter / aux.ml
index 5321349..4709724 100644 (file)
@@ -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