Add /usr/local/lib/faustine and /usr/lib/faustine to preprocessor import path.
[Faustine.git] / interpretor / basic.ml
index 1e56142..ae096af 100644 (file)
@@ -398,3 +398,39 @@ let basic_smaller : basic -> basic -> basic =
       basic_larger_than_zero (b2 -~ b1);;
 
 
+let basic_max : basic -> basic -> basic = 
+  fun b1 ->
+    fun b2 ->
+      let compare = basic_larger_than_zero (b1 -~ b2) in
+      match compare with
+      |        N i -> 
+         if i = 1 then b1
+         else if i = 0 then b2 
+         else raise (Basic_operation "compare result not bool.")
+      |        Vec vec -> 
+         let basics = Array.init vec#size vec#nth in
+         let sum = basic_to_int (Array.fold_left basic_add Zero basics) in
+         if sum = vec#size then b1
+         else if sum = 0 then b2
+         else Error
+      |        Error -> Error
+      |        _ -> raise (Basic_operation "compare result not bool.");;
+
+
+let basic_min : basic -> basic -> basic = 
+  fun b1 ->
+    fun b2 ->
+      let compare = basic_larger_than_zero (b1 -~ b2) in
+      match compare with
+      |        N i -> 
+         if i = 1 then b2
+         else if i = 0 then b1 
+         else raise (Basic_operation "compare result not bool.")
+      |        Vec vec -> 
+         let basics = Array.init vec#size vec#nth in
+         let sum = basic_to_int (Array.fold_left basic_add Zero basics) in
+         if sum = vec#size then b2
+         else if sum = 0 then b1
+         else Error
+      |        Error -> Error
+      |        _ -> raise (Basic_operation "compare result not bool.");;