summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Kerneis2014-03-04 17:31:19 +0000
committerGabriel Kerneis2014-03-04 17:31:19 +0000
commite981ede9b7e662bb238fa53717ab43b49ffefc6c (patch)
tree8faa4b9d924af4d1915c9e78682686d8c69655ba /src
parent791732520b0bb054c466fc19387abdeb122999a6 (diff)
More polymorphism for addition
Diffstat (limited to 'src')
-rw-r--r--src/lem_interp/interp_lib.lem4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lem_interp/interp_lib.lem b/src/lem_interp/interp_lib.lem
index ceefe421..e6c06019 100644
--- a/src/lem_interp/interp_lib.lem
+++ b/src/lem_interp/interp_lib.lem
@@ -54,6 +54,10 @@ let rec add (V_tuple args) = match args with
(if d then to_vec_inc else to_vec_dec) len (V_lit (L_aux (L_num (x+y)) lx))
(* integer case *)
| [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)
+ | [(V_lit(L_aux (L_num _) _) as n); (V_vector len d _ as v)] ->
+ add (V_tuple [(if d then to_vec_inc else to_vec_dec) (natFromNatural len) n; v])
+ | [(V_vector len d _ as v); (V_lit(L_aux (L_num _) _) as n)] ->
+ add (V_tuple [v; (if d then to_vec_inc else to_vec_dec) (natFromNatural len) n])
(* assume other literals are L_bin or L_hex, ie. vectors *)
| [V_lit l; x ] -> add (V_tuple [litV_to_vec l; x])
| [ x ; V_lit l ] -> add (V_tuple [x; litV_to_vec l])