diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-09-27 12:35:27 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-05 14:21:53 +0200 |
| commit | 2952ecc005466775c9ac70a702da1bbad17a28e5 (patch) | |
| tree | cc4743d8615197c48c415455b838767419a63e57 /src/Builtins.hs | |
| parent | 6e55d34719f89192c9141f50638c6dc5bba71dff (diff) | |
Add eq?, lt?
Diffstat (limited to 'src/Builtins.hs')
| -rw-r--r-- | src/Builtins.hs | 17 |
1 files changed, 17 insertions, 0 deletions
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" |
