summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Kerneis2014-04-03 17:18:51 +0100
committerGabriel Kerneis2014-04-03 17:28:45 +0100
commit731bff8e40537176972741014cd88ace55a58742 (patch)
treeee7748ebbb5519d77ff3ae0d73289fe17658f959
parent5e5c61be1edf11c79c2dc3a3517dd7c099116923 (diff)
Implement some arithmetic operations
-rw-r--r--src/lem_interp/interp_lib.lem8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lem_interp/interp_lib.lem b/src/lem_interp/interp_lib.lem
index b9fdb5a1..5315920c 100644
--- a/src/lem_interp/interp_lib.lem
+++ b/src/lem_interp/interp_lib.lem
@@ -57,8 +57,8 @@ let to_vec_dec len (V_lit(L_aux (L_num n) ln)) =
let l = boolListFrombitSeq len (bitSeqFromInteger Nothing n) in
V_vector 0 false (map bool_to_bit l) ;;
-let rec add (V_tuple args) = match args with
- | [V_lit(L_aux (L_num x) lx); V_lit(L_aux (L_num y) ly)] -> V_lit(L_aux (L_num (x+y)) lx)
+let arith_op op (V_tuple args) = match args with
+ | [V_lit(L_aux (L_num x) lx); V_lit(L_aux (L_num y) ly)] -> V_lit(L_aux (L_num (op x y)) lx)
end ;;
let rec vec_concat (V_tuple args) = match args with
@@ -71,8 +71,10 @@ let rec vec_concat (V_tuple args) = match args with
let function_map = [
("ignore", ignore_sail);
- ("add", add);
+ ("add", arith_op (+));
+ ("minus", arith_op (-));
("eq", eq);
+ ("neq", neq);
("vec_concat", vec_concat);
("is_one", is_one);
("to_num_inc", to_num false);