let rec v_mod v1 v2 = match v1 with
|N i1 ->
(
match v2 with
|N i2 -> return_N (i1 mod i2)
|R f2 -> return_N (i1 mod (int_of_float f2))
|Vec (size, vec) -> raise (Value_operation "Scalaire_Vector: int mod vec.")
|Zero -> raise (Value_operation "v1 mod v2: v2 cannot be zero.")
|W -> W
)
|R f1 -> let i = return_N (int_of_float f1) in v_mod i v2
|Vec (size1, vec1) ->
(
match v2 with
|Vec (size2, vec2) ->
if size1 = size2 then
make_vector size1 (fun i -> v_mod (vec1 i) (vec2 i))
else raise (Value_operation "vector size not matched.")
|Zero -> raise (Value_operation "v1 mod v2: v2 cannot be zero.")
|_ -> raise (Value_operation "Vector_Scalaire: vec mod int.")
)
|Zero ->
(
match v2 with
|Vec (size2, vec2) ->
let v = make_vector size2 (fun i -> Zero) in
v_mod v v2
|_ -> v_mod (N 0) v2
)
|W ->
(
match v2 with
|Vec (size2, vec2) -> raise (Value_operation "Scalaire_Vector: int mod vec.")
|Zero -> raise (Value_operation "v1 mod v2: v2 cannot be zero.")
|_ -> W
)