aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Operators.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Operators.hs b/src/Operators.hs
index e607250..45be7f3 100644
--- a/src/Operators.hs
+++ b/src/Operators.hs
@@ -20,6 +20,8 @@ primitives =
20 , ("=", comparator (==)) 20 , ("=", comparator (==))
21 , ("!=", comparator (/=)) 21 , ("!=", comparator (/=))
22 , ("not", unaryBool not) 22 , ("not", unaryBool not)
23 , ("or", naryBool (||))
24 , ("and", naryBool (&&))
23 ] 25 ]
24 26
25data LispNumber = I Integer 27data LispNumber = I Integer
@@ -66,7 +68,9 @@ unaryBool op args
66naryBool :: (Bool -> Bool -> Bool) -> [Expr] -> LispResult Expr 68naryBool :: (Bool -> Bool -> Bool) -> [Expr] -> LispResult Expr
67naryBool op args 69naryBool op args
68 | length args < 2 = throwError $ ArgCount 2 args 70 | length args < 2 = throwError $ ArgCount 2 args
69 71 | otherwise = do
72 as <- mapM unwrapBool args
73 return . BoolLiteral $ foldl1 op as
70 74
71unwrapNum :: Expr -> LispResult LispNumber 75unwrapNum :: Expr -> LispResult LispNumber
72unwrapNum (IntLiteral n) = return $ I n 76unwrapNum (IntLiteral n) = return $ I n