From 2952ecc005466775c9ac70a702da1bbad17a28e5 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 27 Sep 2022 12:35:27 +0300 Subject: Add eq?, lt? --- src/Builtins.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Builtins.hs') diff --git a/src/Builtins.hs b/src/Builtins.hs index 0ddf89f..2dac829 100644 --- a/src/Builtins.hs +++ b/src/Builtins.hs @@ -13,6 +13,9 @@ builtinEnv = M.fromList [ builtinSubtract2, builtinMultiply2, builtinDivide2, + -- comparisons + builtinEq2, + builtinLt2, -- conversions builtinFmt, builtinFloor, @@ -106,6 +109,20 @@ builtinDivide2 = (name, ASTFunction fn1) where fn2 _ ast2 = throwL $ argError2 name ast1 ast2 fn1 _ ast1 = throwL $ argError1 name ast1 +builtinEq2 :: (String, AST) +builtinEq2 = (name, ASTFunction fn1) where + name = "eq?" + fn1 _ ast1 = + return $ ASTFunction $ fn2 where + fn2 _ ast2 = return $ ASTBoolean $ ast1 == ast2 + +builtinLt2 :: (String, AST) +builtinLt2 = (name, ASTFunction fn1) where + name = "lt?" + fn1 _ ast1 = + return $ ASTFunction $ fn2 where + fn2 _ ast2 = return $ ASTBoolean $ ast1 <= ast2 + builtinFloor :: (String, AST) builtinFloor = (name, ASTFunction fn1) where name = "floor" -- cgit v1.3