X-Git-Url: https://scm.cri.mines-paristech.fr/git/Faustine.git/blobdiff_plain/8c48d01c4b78dba6159c13438b06cb7e07a1f338..992d59159547267e1491fcd1c5123765b4c452b8:/interpretor/aux.ml?ds=inline diff --git a/interpretor/aux.ml b/interpretor/aux.ml index 3f75f06..7c21a61 100644 --- a/interpretor/aux.ml +++ b/interpretor/aux.ml @@ -5,11 +5,6 @@ Created: 12/08/2013 Modified: 13/08/2013 *) - -let array_map = fun f -> fun a -> - let n = Array.length a in - Array.init n (fun i -> f a.(i));; - let array_map2 = fun f -> fun a -> fun b -> let n1 = Array.length a in let n2 = Array.length b in @@ -24,3 +19,18 @@ let array_map3 = fun f -> fun a -> fun b -> fun c -> else raise (Invalid_argument "Array.map3 size not matched.");; let decorate = fun s -> " Faustine -> " ^ s;; + +let xor : bool -> bool -> bool = + fun a -> fun b -> (a || b) && (not (a && b));; + +let rint : float -> float = + fun f -> + if (f -. (floor f)) >= 0.5 then ceil f + else floor f;; + +let remainder_float : float -> float -> float = + fun f1 -> fun f2 -> + let r = mod_float f1 f2 in + if (abs_float r) > ((abs_float f2) /. 2.) then + (if r *. f2 > 0. then (r -. f2) else (r +. f2)) + else r;;