diff options
Diffstat (limited to 'src/lem_interp/interp_lib.lem')
| -rw-r--r-- | src/lem_interp/interp_lib.lem | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lem_interp/interp_lib.lem b/src/lem_interp/interp_lib.lem index 4cda3316..b20647fb 100644 --- a/src/lem_interp/interp_lib.lem +++ b/src/lem_interp/interp_lib.lem @@ -1,9 +1,20 @@ +open import Pervasives open import Interp open import Interp_ast import Maybe_extra open import Num open import List +let compose f g x = f (V_tuple [g x]) ;; + +let eq (V_tuple [x; y]) = V_lit (if x = y then L_true else L_false) ;; + +let neg (V_tuple [V_lit arg]) = V_lit (match arg with + | L_true -> L_false + | L_false -> L_true end) ;; + +let neq = compose neg eq ;; + let add (V_tuple [V_lit(L_num x); V_lit(L_num y)]) = V_lit(L_num (x+y)) ;; let rec vec_concat (V_tuple args) = match args with @@ -15,6 +26,7 @@ let rec vec_concat (V_tuple args) = match args with let function_map = [ ("add", add); ("add_infix", add); + ("=", eq); (":", vec_concat); ] ;; |
